+ 2

Guess output of this java code ...

public class Test { public void foo(String s) { System.out.println("String"); } public void foo(StringBuffer sb){ System.out.println("StringBuffer"); } public static void main(String[] args) { new Test().foo(null); } }

25th Jul 2017, 12:20 PM
Master Gaurav
3 ответов
+ 2
u need to declar a static method for ex: public static void foo(...){...} and in the main function u need to create: Test.foo(null); // class Test static or creat a varibale before new Test() Test t=new test(); t.foo();
25th Jul 2017, 1:34 PM
Yassine Sellami
0
It's an error
25th Jul 2017, 12:42 PM
Jonas Schröter
Jonas Schröter - avatar
0
That's not the problem, try in playground.
25th Jul 2017, 1:38 PM
Jonas Schröter
Jonas Schröter - avatar