|
1.4 Command-Line argument
Array / Pointer is the most important thing in C. On another hand, they are most difficult thing in C too. After learning the behavior of stack, it will make beginner headache for couples of weeks.
On my short experience of being a teacher, I “heard” that Jave ban pointer because of some reasons. Pointer is quite good after you master it and also quite bad before you master it. It is said that some fans of pointer have successfully use pointer in Java but I think that is not necessary. Good for use and increase the robust of your program is the most important thing in application.
Let’s back to Array. Since the No.1 trouble-maker is not exist in Java, Array (with out pointer of array) is not so difficult.
See the program itself. Find out where to input the argument trouble me most because I am not familiar with eclipse. Finally I find it in: Run->Open Run Dialog->Arguments.
Find my program as follow. Take care I have reverse the order of arguments.
for(int i=1; i<=args.length; i++)
System.out.print(args[(args.length-i)]+" " ;
I find I make a same mistake with author because I leave a useless blank in end of output. But I have not find a good way to eliminate the extra blank & keep program in short, I decide skip this small annoyance |
|