94

I know a cool shortcut for System.out.println(): sysout Ctrl + Space.

Is there something similar for public static void main(String args[])?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199

8 Answers8

228

This is just main and Ctrl-Space.

Matt Ball
  • 354,903
  • 100
  • 647
  • 710
corsiKa
  • 81,495
  • 25
  • 153
  • 204
50

In Eclipse, select preferences.

In preferences, look for Java/Editor/Templates.

Here you will see a list of all of them. And you can even add your own.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
19

Just type ma and press Ctrl + Space, you will get an option for it.

mtk
  • 13,221
  • 16
  • 72
  • 112
Vishwa
  • 191
  • 1
  • 2
5

As bmargulies mentioned:

Preferences>Java>Editor>Templates>New...

enter image description here

enter image description here

Now, type psvm then Ctrl + Space on Mac or Windows.

raja777m
  • 401
  • 1
  • 8
  • 18
1

Type main and press and hold Ctrl and next press Space Space (double space) and select, it or pressenter to focus on main option.

This is fastest way.

hat
  • 781
  • 2
  • 14
  • 25
1

To get public static void main(String[] args) line in eclipse without typing the whole line type "main" and press Ctrl + space then, you will get the option for the main method select it.

enter image description here

AzarEJ
  • 552
  • 1
  • 5
  • 16
0

Alternately, you can start a program containing the line with one click.

Just select the method stub for it when creating the new Java class, where the code says,

Which method stubs would you like to create?

[check-box] public static void main(String[]args) <---- Select this one.

[check-box] Constructors from superclass

[check-box] Inherited abstract methods

-1

Just type main and press Ctrl + Space, and you will get an option for it.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 09 '22 at 03:17
  • This has already been stated in the accepted answer. – Attila T Nov 11 '22 at 16:37