Created
September 12, 2014 10:18
-
-
Save SubOptimal/add86cc4b1f4a141c382 to your computer and use it in GitHub Desktop.
Java "Hello World" without keyword "class"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux / Mac | |
echo 'java.lang.System.out.println("Hello World")' | java -cp ${JAVA_HOME}/lib/tools.jar com.sun.tools.script.shell.Main | |
# Windows | |
echo java.lang.System.out.println("Hello World") | java -cp %JAVA_HOME%/lib/tools.jar com.sun.tools.script.shell.Main |
Btw. you don't need the "public" modifiert in interfaces so you can make it even shorter ;-)
@yfain Sure your interface solution is more readable. Mine was more to show a "more different" solution. ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice solution!
This one is more readable though:
public interface HelloWorldInterface {
public static void main(String[] args) {
System.out.println("HelloWorldInterface World");
}
}