| |
2. 1. 9. 显示默认的初始值 |
|
public class MainClass {
boolean t;
char c;
byte b;
short s;
int i;
long l;
float f;
double d;
void print(String s) {
System.out.println(s);
}
void printInitialValues() {
print("Data type Initial value");
print("boolean " + t);
print("char [" + c + "]");
print("byte " + b);
print("short " + s);
print("int " + i);
print("long " + l);
print("float " + f);
print("double " + d);
}
public static void main(String[] args) {
MainClass iv = new MainClass();
iv.printInitialValues();
}
}
|
|
Data type Initial value
boolean false
char []
byte 0
short 0
int 0
long 0
float 0.0
double 0.0 |
|