• Post Reply Bookmark Topic Watch Topic
  • New Topic

why am I getting compile time error?  RSS feed

 
raja singh kumar
Ranch Hand
Posts: 189
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two code samples below. When I am extending Thread class I am able to call start method without any invoking object. But when implementing Runnable interface if I try to use start without an invoking object it gives compile time error saying "method is undefined".

1. Why the difference?
2. Also when I am able to call start method without invoking object is there is an implicit this?





 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your class ThreadDemo1 does not have a method named start.

Call that method on the Thread object: t.start(); in line 6 instead of just start();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!