Java Syntax
Now, we are creating a Java file named ‘A’. In Java, the class name and the .java file name can be different; however, if the class is declared as public, the file name must match the class name exactly. By default, every Java program automatically imports the java.lang package, so there is no need to import it explicitly.
1) public : - To make main () method global because the JVM (Java Virtual Machine) is the outside part of the JRE.
2) String : - Because string is easy to access all types of data types' values, it means string can take float, int, and double values easily, and it is easy to convert into other formats.
3) System :- System is a class, and println is a method.
4) out :- In the System class, out is a static class variable of the PrintStream class
5) println() :- It is not a method of the System class; it is a method of a PrintStream class. This class belongs to the java.io. package.
Code Example
class A
{
public static void main(String arg[])
{
System.out.println(" hello ");
}
}
FAQs
public static void main(String[] args)
public → Accessible by JVM
static → Called without creating an object
void → Does not return any value
RANREV INFOTECH