Can't find system.out.println()

2019-01-30 10:04发布

问题:

I created a project, it asked me to select JDK version and finish.

I couldn't find system namespace in autocomplete.

I typed it manually but IDEA told me that system doesn't exist.

回答1:

It's System (with a cap)

Some very useful shortcuts:

soutm (+TAB) ==> System.out.println("Class.And.Method.Name")
soutv (+TAB) ==> System.out.println("Last variable used = " + value);
sout (+TAB) ==> System.out.println();

I really love IntelliJ. Glad I moved to it from Eclipse a couple of years ago ;)



回答2:

Just type sout.

public class Main {

public static void main(String[] args) {
    int data = 1;
    System.out.println(); ===>sout 
    System.out.println("Main.main"); ===>soutm 
    System.out.println("args = [" + args + "]"); ===>soutp 
    System.out.println("data = " + data); ===>soutv 
}

}

sout - just print System.out.println()

soutm - added Class name & method name

soutp - added parameter

soutv - added last variable name



回答3:

We can change the auto complete settings to to ignore case. Go to:

File -> Settings... -> IDE Settings -> Editor -> Code Completion 

and change 'Case sensitive completion' to 'None'.



回答4:

I came from eclipse and was using the syso shortcut, so I have just added it to my live template. Here is a templete:

System.out.println($END$);

Here is a screenshot:

Don't forget to add Java as applicable context (at the bottom of the window).
Now it will appear as a hint while you typing syso here is a screenshot:

Hope it helps



回答5:

This can also happen because user has not created any main function or trying to test this directly in class without any function