0

Why does this code not has output?

class MyThread extends Thread{ public void run (int i){ System.out.print("i"); } } class ThreadDemo{ public static void main(String [] args){ MyThread t = new MyThread(); t.start(); } }

2nd Jul 2018, 12:32 PM
Afresia
Afresia - avatar
3 Antworten
+ 9
From what I recall, it is because the run method of the Runnable interface requires no arguments to be passed in. In your case, int i shouldn't be there as a parameter of the run method. https://docs.oracle.com/javase/8/docs/api/java/lang/Runnable.html#run-- There maybe any another reason, as I'm not pretty sure about it. :\
2nd Jul 2018, 12:42 PM
Dev
Dev - avatar
+ 1
no return statement
2nd Jul 2018, 2:25 PM
lbaum
lbaum - avatar
0
theres no output
3rd Jul 2018, 1:31 PM
Kelvin A
Kelvin A - avatar