+ 1

method

class MyClass { static void sayHello(String name) { System.out.println("Hello " + name); } static void rollno(int rollno){ System.out.println("rollno is"+ rollno); } public static void main (String args[]){ sayHello ("eshaan"); } public static void main (int rollno){ rollno("16543"); } } can any body tell me why this code not running

2nd Aug 2017, 8:53 AM
Eshaan Belani
5 Respostas
+ 2
try to replace 2nd main by calling rollno(16543);
2nd Aug 2017, 9:17 AM
Dina
Dina - avatar
+ 1
because of 2 main methods! it must be only one main in the whole program
2nd Aug 2017, 9:09 AM
Dina
Dina - avatar
+ 1
okk thanku very much
2nd Aug 2017, 9:18 AM
Eshaan Belani
0
can you please explain it by writing
2nd Aug 2017, 9:15 AM
Eshaan Belani
0
/*your trying to turn an int to string heres your working code*/ class MyClass { static void sayHello(String name) { System.out.println("Hello " + name); } static void rollno(int rollno){ System.out.println("rollno is "+ rollno); } public static void main (String args[]){ sayHello ("eshaan"); rollno(1234); }}
2nd Aug 2017, 10:07 AM
D_Stark
D_Stark - avatar