• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runnable Issue

 
awad saleh
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone..

As we know we create an object of interface. Then why the below program is getting executed..?
I need an explanation how it is getting executed.....?


public class Test {
public static void main(String[] args) {
new Thread(new Runnable() {
public void run() {
System.out.println("Hello!");
}
}).start();
}
}


Thank Q.
 
arulk pillai
Author
Ranch Hand
Posts: 3388
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is creating an inner class and executing the run() method. Have a look at Java inner classes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic