projet IDEA dans le nouveau projet
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();
}
}
Deux nouvelles 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);
}
}
résultat
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