public class game extends Thread{
public void run() {
System.out.println("Sub-class must override the void run() method of Thread class!");
}
public static void main(String args[]) {
Thread t = new Thread();
t.start();
}
}
For these lines of code above I got nothing in the console. But for these codes below:
public class game extends Thread{
public void run() {
System.out.println("Sub-class must override the void run() method of Thread class!");
}
public static void main(String args[]) {
game g = new game();
g.start();
}
}
I got "Sub-class must override the void run() method of Thread class!" shown in the console.
Could you help me, why I need to create an object of the sub-class rather than an object of the Thread class? What's the difference? Sorry I am a total novice.