Strange Hello World in Java
Overview
This is a strange Hello World program because it only needs to be compiled, not run. How does it work? Hint: it only works on MS-DOS/Windows. ;)The Program
In a file called A.java or any name exception Con.javaclass Con { String hi = "\n\n\tHello World!\n\n"; }when compiled produces
How does this work
MS-DOS/Windows treats all files which start with CON (in any case and with any extension) as the console. So when javac writes the Con.class file, it is written to the console instead.In the MS world; its not a bug, its a feature.
Very interesting
ReplyDelete