java - why void method can not be called in system.out.println -


can please answer why code giving error?

package hello;  public class hello {      public void eat() {         system.out.println("eating");     }      private string run() {     return "dwedsdfsdfsdf fsdf rgdsfg";      }      public static void main(string[] args) {         //system.out.println("hello bhopi");         //hello hello = new hello();         hello mahir = new hello();         //string y = mahir.eat();          system.out.println(mahir.run());         system.out.println(mahir.eat());     } } 

1) no method may accept parameter invocation void method.
if pass void argument method.

2) here println() refers printstream.println() method out field declared printstream.
compile fine when invoke it, have specify argument matches 1 of overloaded versions of method.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -