Java Program to Print Statement without Semicolon

This is a Java Program to Print any Statement without using Semicolon.

We use statements like if and for to print any statement without using semicolon. Since these statements do not require semicolons at the end of these statements, we use them to get desired output.

Here is the source code of the Java Program to Print any Statement without using Semicolon. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.

  1. public class Print_Without_Semicolon 
  2. {
  3.      public static void main(String[] args) 
  4.      {
  5.         int i = 0;
  6.         if(System.out.printf("Sanfoundary!! ") == null) {}
  7.         for(i = 1; i < 2; System.out.println("Hello World."))
  8.         {
  9.             i++;
  10.      	}
  11.      }
  12. }

Output:

$ javac Print_Without_Semicolon.java
$ java Print_Without_Semicolon 
 
Sanfoundary!! Hello World.

Sanfoundry Global Education & Learning Series – 1000 Java Programs.

advertisement
advertisement

Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.