代码:
public class TestVariate {
static int si;
static char sc;
static boolean sb;
public static voidmain(String[] args)
{
int i = 1; // 范围:正负20亿,存储:4字节
long l = 1; // 存储:8字节
char c = 'c'; // 字符
boolean b = true;// 布尔
System.out.println(i);
System.out.println(l);
System.out.println(c + " " + (int)c);
System.out.println(b);
System.out.println(si);
System.out.println((int)sc);
System.out.println(sb);
System.out.println(++i + " " + i++ ); // 从左到右计算
System.out.println(i++ + " " + ++i );
System.out.println(15/2 + " " + 15%2);
System.out.println(2/0.0);
}
}
打印结果:
1
1
c 99
true
0
0
false
2 2
3 5
7 1
Infinity