Reputation: 85
When we create a new class file in eclipse the steps we follow is
if we want a main class we click on the checkbox
public static void main(String[] args)
But suppose we don't click the checkbox and create a .java file, is there a way
to generate public static void main(String[] args)
from the source, just like the way we generate getter/setter from source in eclipse.
PS: I know we can write public static void main(String[] args) manually, but I just want to know if eclipse has any feature to do that.
Upvotes: 1
Views: 1668
Reputation: 383
You can write "main" and hit Ctrl+Space to generate the main method. In IDEA IntelliJ the alias is "psvm".
Upvotes: 5
Reputation: 1258
Eclipse does nothing you can't do your self just try it. Create a new class call it what ever you want then create public static method called main which has a return type of void and excepts String array and you are done here is an example
public class IWantCacke {
public static void main (String ...sdadasda){
System.out.println("Welcome to my main");
}
}
What youn need to understand that methods with the signature public static void main (String ...someArgName)
are special methods that tell your program where to start you can create this method in any class it is static because it is born before any other object in your program
Upvotes: 0