The problem is that h is not a String, it's an array of Strings. An array is basically a set of "things" stored together. So you could have int[] a = new int[2]; and that would look like this:
The above diagram shows 2 boxes (i.e. an array of two items). To access box one, you would type a[0], and to access box two you would type a[1], so what you need to do in your program is:Code:___ ___ | || | | || | --- --- 0 1
I would advise you to look up arrays on the internet (java arrays specifically) if you didn't understand what I wrote above. Good luck,Code:public class FirstClass { public static void main(String h[]) { System.out.println(h[0]); // this accesses the first string stored in h // i.e. the first command line parameter } } /* so if you type: java FirstClass one you would get: One as output because one is the first command line parameter after the program name*/
Adam




Reply With Quote