命令行参数示例(实验):
public class Test {
public static void main(String[] args){
if(args.length==0){
System.out.println("you don't set command line parameters!");
}else{
for (int i=0; i<args.length; i++){
System.out.println("args[" + i + "] is: " + args[i]);
}
}
}
}
when use eclipse, don't "run as application",directly use "run configurations/run", then add in aguments in program arguments.(当运行eclipse,不要"run as application",而直接用"run configurations/run",然后加上参数在,program arguments.)
result is:
args[0] is: 马克-to-win
args[1] is: 的
args[2] is: 书
下图是有关非eclipse命令行的实验:
8.3 Arrays of Arrays(1)
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
An array that contains other arrays as its elements.(一个数组中包含其他的数组作为它的元素)
public class TwoDimentional {
public static void main(String[] args) {
char[][] table= new char[2][4];
char[] row0 = {'A','B','Z','M'};
char[] row1 = {'C','D','K','L'};
table[0] = row0;
table[1] = row1;
for(int i=0; i<2;i++){
for(int j=0;j<4;j++){
System.out.println(table[i][j]);
}
}
}
}
result is:
A
B
Z
M
C
D
K
L