Wednesday, February 20, 2008

Experiment Time

Netbeans is NOT the place where one can gain expertise in java! So if you are a novice, I say-"stick to routines". Just to make my point felt, I want to cite an example. Consider this program.

class Fun
public static void main(String[] args)
int count,i=0;
String words;
System.out.println("Number of arguments= " +count);
while (i < count)
System.out.println(i+ ":" + "Java is " +words+ "!");

Execute this program in jdk and at the command for compilation,give the following statement(let your filename be Fun!)

java Fun Robust Simple Secure Portable Multithread

The output of your program would be as follows:

Number of arguments=5
1: Java is Robust!
2: Java is Simple!
3: Java is Secure!
4: Java is Portable!
5: Java is Multithread!

Isn't this such a cool output!!! Now, you know the use of String[] args!!! If you were a starter, I sure can swear that you wouldn't have figured this out.. As far as my knowledge with netbeans goes, I don't think there is an option where I can provide arguments at run-time.. (If there is that option, I am yet to discover it then!!)

No comments: