Uzi's Blogs

Things I learn, observe and try out

Thursday, June 09, 2005

Interesting Java program


This is perhaps the most interesting java behavior that I have encountered. Try to guess the output before actually compiling it and running it.

public class Guess {
public static void main(String args[]) {
for(int i=0;i<=args.length;i++){
System.out.println(args[i]);
}
}

Run this program as follows:
>java Guess *

If you think that program will produce * as output, then you are wrong my brother, you need to try it out yourself :)

--Uzi

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home