5.public static void main(String[ ] args){ }
其中args接收程序运行时显示的任何命令行参数
public static void main(String[ ] args){
for(int i = 0;i<args.length();i++){
System.out.print(args[i]+" ");
(System是预定义的可访问系统的类,out是连接到控制台的输出流)
}
}
6.java标识符
一个标识符可以使大写,小写字母,数字,下划线,$符号的任意顺序组合,但不能以数字开头。
7.java中8中基本数据类型
(java对数据类型兼容性的要求比任何语言都要严格)
字节型(byte)>>1字节 短整型(short)>>2字节 整型(int)>>4字节
长整型(long)>>8字节 浮点型(float)>>4字节 双精度型(double)>>8字节
字符型(char)>>2字节 布尔型(boolean)>>1位
java中数学运算结果至少int类型,如果操作数大于int类型,结果就与较大范围操作数数据类型一致。
例如:byte i = 5;
byte j = 9;
byte d = i+j;
System.out.print(d);(语法错误)
8.java中的i++与++i
x = 42; x=x+1;
y = ++x; 等价于 y = x;
x = 42; y = x;
y = x++; 等价于 x=x+1;
再例如:
public static void main(String[] args){
int a = 1;
int b = 2;
int c;
int d;
c = ++b;
d = a++;
c++;
System.out.print("a = "+a);
System.out.print("b = "+b);
System.out.print("c = "+c);
System.out.print("d = "+d);
}
运行结果:a = 2;
b = 3;
c = 4;
d = 1;