File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runnable Issue

 
awad saleh
Greenhorn
Posts: 22
  • 0
  • 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: 3380
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic