Main method can be created in the below ways:
public static void main(String[] args) {}
public static void main(String molecules[]) {}
static public void main(String[] gadgets) {}
static public void main(String spaces[]) {}
public static void main(String ... countries) {} //String three dots(...) args/any variable name
static public void main(String ... data) {}
1. public and static can appear in any order in main function
2. [] can appear before or after the variable name
3. as of java 5 [] can be replaced with ...(three dots), but it should appear between String and the variable. 9This feature is called var-args and has been added in java 5.0. You can use var-args in any method or constructor. It must be the last arguments. you can pass only one var-arg argument. var-arg argument is considered as a array. so a class cannot have 2 methods one havin g a array of String and another having only var-args of String)
4. the most important is that argument's name can be anything ie instead of args we can name it with our own name.
i think these are the ways main method can be written.
I Read 20+ Spring Boot Books: Here Are My Top 6 Recommendations
-
Spring framework is one of the most famous structures in the Java world,
which used to develop Java applications, both core Java and web
application. It i...
17 hours ago
No comments:
Post a Comment
I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.