How To Print Hello World in Java Without Semicolon

If you’re a Java programmer then you know how much respect you must give to this little semicolon. No program is completed without it, and due to this no one even thinks about writing a Java program without a semicolon. But what if you could write some simple Java programs to print statements like hello world without a semicolon. In this article, we will tell you exactly how to do that. So let’s get straight to the tutorial.

We will be showing you different ways of printing statements without semicolons in Java so that you can use whatever method you like to impress your classmates, friends or even your crush if he/she likes programming.

 

Hello World in Java Without Semicolon With

 

1) If Statement

 

// Java program to print Hello World without semicolon using if statement

class Techdecodetutotials 
{
    public static void main(String args[])
    {
        if (System.out.printf("Hello World") == null)
                {
        }
    }
}


Output:

Hello World

2) for loop

 

// Java program to print Hello World without semicolon using for loop

class Techdecodetutotials 
{
    public static void main(String args[])
       {
        for(int i = 0; i < 1; System.out.println("Hello World")) 
                {
            i++;
        }
    }
}

Output:

Hello World

3) StringBuilder.append() Method

 

// Java program to print Hello World without semicolon using append method of String class

class Techdecodetutotials

 {

    public static void main(String[] args)
    {
        if (System.out.append("Hello World") == null) 
                {

        }
    }
}

Output:

Hello World

4) String.equals() Method

 

// Java program to print Hello World without semicolon using equals method of string class
class Techdecodetutotials
 {
    public static void main(String args[])
    {
        if (System.out.append("Hello World").equals(null)) 
               {

        }
    }
}

Output:

Hello World

If you want to know no more about why we use semicolons in programming languages then read this Role of SemiColon in various Programming Languages from geeks for geeks.

 

Also Read: How To Run Java in Visual Studio Code on Windows 10

Ethix

I'm a coding geek interested in cyberspace who loves to write and read

Leave a Reply

Your email address will not be published. Required fields are marked *