Role of Main Method
Sakshi Agrawal
immediate joiner | Backend Developer | Java |Spring Boot|Microservices|Hibernate|Jenkins|Bitbuket|Kubernetes|kafka|Putty|Cassandra|Software Engineer
Hello to my all Readers!....
Hope You All are having good Reading
Below I'm sharing my weekly learning regarding Technical Concept (Java Language). Have a glance on this and enjoy your reading.
The most important method in java i.e "Main Method"
What is main method?
Syntax of main method?
public static void main(String[] args);
As per the rule method should be called so, main method automatically executing?
-----------------------------------------------------------------
What is the use of main method?
------------------------------------------------------------------
If Class doesn't have main method?
Class will not execute and JVM will throw error. that is we can compile the class but at the time of execution we will be getting error. Therefore main method is mandatory for?execution only. For just compiling a class main method isn't required.
----------------------------------------------------------------------
Can we change the parts of main method?
Except "args" we aren't allowed to change or remove the main method other parts. We will get either CE or RE.
???????????public static void main(String krish[]);
???????????public static void main(String args[]);
??public?static void main(String[] args);
?
public static void main(String… args);
? String...args:?It allows the method to accept zero or multiple arguments. There should be exactly three dots?between String and array; otherwise, it gives an error.
Public static void main(String[] args);
static public void main(String[] args);
------------------------------------------------------------------
Why main method has public?
------------------------------------------------------------------
Why main method has static?
领英推荐
---------------------------------------------------------------------
Why main method has void?
------------------------------------------------------------------------
Why main method name is main?
-------------------------------------------------------------------------
Why main method has parameter?
-------------------------------------------------------------------------
Why main method parameter type is array?
? --------------------------------------------------------------------------
Why main method parameter type is string[] ?
-------------------------------------------------------------------------------?
Why main method parameter name is args?
? -----------------------------------------------------------------------------------
Can we call main method explicitly?
-----------------------------------------------------------------------------------
What happens if the main() method is written without String args[]?
?Execution Process
??
Thankyou For Reading!
Published by:?Sakshi Agrawal
Date?:?March 30,2022
?
?