Simple program in Java | Hello world Example


Simple program in Java | Hello world Example

We will create a file called Main.java and we use the following code to print "Hello learnwithvaigandla" to the screen.

Main.java

public class Main {
              public static void main(String[] args) {
                System.out.println("Hello learnwithvaigandla");
              }
            }
            

Every line of code that runs in Java must be inside a class. In our example, we named the class Main. A class should always start with an uppercase first letter.

Note: Java case sensitive so that 'Class' and 'class' has different meaning.

The name of the file is must match with the class name. when you are saving the file, save it using class name and add '.java' to the end of the filename.

Output

Hello learnwithvaigandla

Explination of Parameters:

  • class:
    'class' is a keyword is used to declare a class in Java.
  • public:
    'public' is a keyword is an access modifier that represents visibility. It means it is visible to all.
  • static:
    'static' is a keyword. If we declare any method as static, it is known as the static method.
  • void:
    'void' is the return type of the method. It means it doesn't return any value.
  • main:
    'main' represents the starting point of the program.Any code inside the main() method will be executed and every program must contain the main() method.
  • String args [ ] or String [ ] args:
    'String args[ ]' is used for command line argument.
  • System.out.println():
    'System.out.println()' is used to print statement. Here, System is a class, out is an object of the PrintStream class, println() is a method of the PrintStream class

Features of JAVA

There is given many features of java.They are also known as java buzzwords. The Java Features given below are simple and easy to understand.

About JAVA

Learn About JAVA and It's Origin
Java is an efficient powerful object-oriented language developed in the year of '1991'.




Comments

Popular posts from this blog

What is Object Oriented Programming in Java?

A Comprehensive Guide to Java and Its Applications: Exploring the Versatility of Java Programming