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.
public class Print_Without_Semicolon
{
public static void main(String[] args)
{
int i = 0;
if(System.out.printf("Sanfoundary!! ") == null) {}
for(i = 1; i < 2; System.out.println("Hello World."))
{
i++;
}
}
}
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.
Related Posts:
- Practice BCA MCQs
- Check Java Books
- Check Programming Books
- Practice Programming MCQs
- Apply for Java Internship