Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ System.out.println() - Cannot resolve method println(java.lang.String)

I am using IntelliJ IDEA, learning Java. All went well until yesterday, when the mentioned error occurred.

I didn't make any changes. I was looking for the solution the following ways:

  1. reboot the pc
  2. restart IntelliJ.
  3. delete the project directory and use another one (both on desktop)

nothing helps. buy running simple hello world method. It keeps showing this error:

screenshot

Is there someone able to help me?

like image 591
user6479494 Avatar asked Jul 28 '16 11:07

user6479494


People also ask

What is Cannot resolve method in Java?

In JavaLanguage, if you get 'cannot resolve symbol', you have used a name that the compiler hasn't recognized. Class names -- If it is a class name, the compiler cannot find the class.

What does system out Println mean?

In Java, System. out. println() is a statement which prints the argument passed to it. The println() method display results on the monitor. Usually, a method is invoked by objectname.


3 Answers

ok, is solved.

file -> invalidated caches / Restart

like image 112
user6479494 Avatar answered Oct 12 '22 03:10

user6479494


I think if you have tried the method above, maybe you can consider where you use System.out.println() because this method should only used in main(String args[]){},the latest version of the Idea is OK. I wish what said can help you.

like image 40
tom Tao Avatar answered Oct 12 '22 03:10

tom Tao


One reason for this to happen is if you have print statement somewhere on the body of the class, and not inside a method.

Here is an example:

enter image description here

But if the print is inside a method, it should work fine.

Here is an example:

enter image description here

like image 16
z atef Avatar answered Oct 12 '22 03:10

z atef