[Java] llevado a cabo mediante una llamada a la clase java IDEA

proyecto IDEA en el nuevo proyecto

Main.java

package com.company;

public class Main {

    public static void main(String[] args) {
	// write your code here
        System.out.println("Hello world");

        test test1 = new test();
        test1.prin();
        test1.apped();
        test1.apped();
        test1.apped();
        DataType data1 = new DataType();
        data1.type();
    }
}

Dos nuevos java

test.java

package com.company;

public class test {
    int i = 0;
    public void prin(){
        System.out.println("test");
    }
    public void apped(){
        i++;
        System.out.println("apped:"+i);
    }
}

DataType.java

package com.company;

public class DataType {
    static boolean bool;
    static byte by;
    static char ch;
    static float f;
    static double d;
    static int i;
    static long l;
    static short sh;
    static String str;
    public static void type(){
        System.out.println("Bool :"+bool);
        System.out.println("Byte :"+by);
        System.out.println("Character:"+ch);
        System.out.println("Double :"+d);
        System.out.println("Float :"+f);
        System.out.println("Integer :"+i);
        System.out.println("Long :" +l);
        System.out.println("Short :"+sh);
        System.out.println("String :"+str);

    }
}

resultado

Hello world
test
apped:1
apped:2
apped:3
Bool :false
Byte :0
Character: 
Double :0.0
Float :0.0
Integer :0
Long :0
Short :0
String :null

Process finished with exit code 0

 

Publicados 201 artículos originales · alabanza won 46 · Vistas a 90000 +

Supongo que te gusta

Origin blog.csdn.net/rong11417/article/details/105015645
Recomendado
Clasificación