• Post Reply Bookmark Topic Watch Topic
  • New Topic

is Runnable an interface or a class?  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is Runnable an interface or a class???


Because i saw one example where it was given

Runnable r=new Runnable();
 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its an Interface. You can look up the Documentation for any such doubts. And can you please show us the code where this was being used- Might be as an Anonymous Inner class.
 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try this:

 
Pawan Kr Gupta
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear, Runnable is an interface not a class
 
Ed Connery
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joachim Heidenreich wrote:you could try this:


Yes, to quote Sierra & Bates: "...it's instantiating an implementer of the Runnable interface (an anonymous implementation class)" (SCJP pg 678)

The OP gave the matching example: "The following is not legal..."
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:is Runnable an interface or a class???

You can also download the source code .
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad Khojaye wrote:You can also download the source code .

You don't even need to download it separately, because it's already in the installation directory of the JDK (look for the file src.zip).
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad Khojaye wrote: . . . You can . . . download the source code
Or you can look in the API, where it clearly says
public jkdfgkdsjfgkjd Runnable
. Only my spelling has gone to pot
 
Alex Hurtt
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Hegde wrote:is Runnable an interface or a class???


Because i saw one example where it was given

Runnable r=new Runnable();


If you really saw this, exactly as you put above, and it compiles, then it wasn't a java.lang.Runnable.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is more likely you sawThat is an anonymous class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!