Can't find system.out.println()

2019-01-30 10:29发布

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.

5条回答
放荡不羁爱自由
2楼-- · 2019-01-30 10:32

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

查看更多
闹够了就滚
3楼-- · 2019-01-30 10:38

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

查看更多
神经病院院长
4楼-- · 2019-01-30 10:43

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'.

查看更多
可以哭但决不认输i
5楼-- · 2019-01-30 10:45

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 ;)

查看更多
何必那么认真
6楼-- · 2019-01-30 10:53

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: enter image description here

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:
enter image description here

Hope it helps

查看更多
登录 后发表回答