Create a java project in IDE. Create package in src and java class in that package.
public class demoFirstProgram {
public static void main(String[] args){
System.out.println("This is my first program in java");
}//End of main
}
Explanation of the Code:
public static void main(String[] args) {
This is our next line in the program, lets break it down to understand it:
public
: This makes the main method public that means that we can call the method from outside the class.
static
: We do not need to create object for static methods to run. They can run itself.
void
: It does not return anything.
main
: It is the method name. This is the entry point method from which the JVM can run your program.
(String[] args)
: Used for command line arguments that are passed as strings.
System.out.println("This is my first program in java");
This method prints the contents inside the double quotes into the console and inserts a newline after.
You can Mail is you face any issues.
Mail: rajan.sethi36@gmail.com
Thanks.