Explanation for the above syntax -
class - Java is a pure object oriented programming, so that every development start with class.
FirstjavaApp - It is a class name / project name / application name
public static void main(String[] args)
main() - It is predefined with user-defined logics. Why main() ? In java of JSE, JVM will invoke from entire JSE project only "main" method. So that main is mandatory for execution. According to the above point in JSE whatever I want to execute, then that execution logic i should write inside of the main method.
How JVM will invoke "main" method from JSE project ?
To invoke main() method at runtime JVM is passing some requirement, andthat requirement are multiple and type is String. So that I should write String[] args inside of main method in the following ways - main(String[] args) or main(String args[])
void main(String[] args) - In main method there is no any return type statements. So that we have void. Here void is non return type.
static void main(String[] args) - In java going on we will work with different types of methods. So here main is static method.
public static void main(String[] args) - With the help of public we can use and write main() method in any place.
System.out.println("hello java") - out is a static variable inside of System class. println is a method from PrintStream class. Using this we can print the requirement. When we call println() method from System.out then we get println() method of output in console screen.
No comments:
Post a Comment