Photo of DeepuDeepu Mohan Puthrote

· 1 min read in Java

Java :: Print "Hello World" without using Semicolon (;)

This Gist shows how to print something in Java, without the use of Semicolon (;). The code is self explanatory.

This idea is to use System.out.println() inside the brackets of an if().

if() will evaluate it’s expression without the need for semicolon.

PrintWithoutSemiColon.java
public class PrintWithoutSemiColon {
public static void main(String[] args) {
if (System.out.printf("Hello World!\n") == null) {}
/**
* This one is given by Salil Joshi, in the following LinkedIn discussion
* http://www.linkedin.com/groups/How-print-Hello-World-in-3983267.S.252703117?qid=1ce0f1f0-73f3-4c31-ba37-c27aa8e81b55&trk=group_most_popular-0-b-ttl&goback=%2Egmp_3983267
*/
if (System.out.append("Hello World!\n").equals(null)) {}
}
}

https://gist.github.com/WarFox/5847999