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

why is this not compiling

 
james oberon
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


[ EJFH: Added CODE tags to preserve formatting. ]
[ January 23, 2006: Message edited by: Ernest Friedman-Hill ]
 
avelin chen
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the compiler say?
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the compiler error that you get so that we can explain what the message means.

Layne
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Want to tell us what the compiler error message was? Sure would make this go a lot faster.
 
james oberon
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
says lab not abstract and does not override abstract method in line number 4
 
Henry Wong
author
Marshal
Pie
Posts: 20829
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by james oberon:
says lab not abstract and does not override abstract method in line number 4


Compiled and ran fine here ... I am using Java 1.4.2.

Henry
 
Jon Egan
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,

This means the interface you are implementing ("ActionListener") defines more methods than what you have implemented.

Any class that implements an interface has to provide implementations of every method in the interface, or it's not "complete". You could acknowledge to the compiler that you know the class is incomplete, by declaring your class to be "abstract". But then, you still couldn't instantiate one of your Listeners until you created a subclass of that, that defined the remaining methods from the AbstractListener interface.

So, the compiler is saying, you had two options to make this thing compile:
  • define your class as abstract, admitting you left it incomplete, or
  • finish the job and provide implementations for everything left out of AbstractListener


  • By leaving off the "abstract" declaration from your class, you are asserting it is complete. The compiler doesn't agree....

    Hope this helps.
    -- Jon
    [ January 23, 2006: Message edited by: Jon Egan ]
     
    Layne Lund
    Ranch Hand
    Posts: 3061
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by james oberon:
    says lab not abstract and does not override abstract method in line number 4


    This still doesn't look like the exact error message. For instance, you don't state what abstract method the compiler says you are supposed to override. If you can, you should copy and paste the whole error message here so you don't lose important details like this. If not, then you should type it WORD FOR WORD.

    With that said, I don't understand why it would give you this error message. The Lab35B class implements ActionListener and you have overriden the actionPeformed() method correctly from what I can tell. I think this should compile just fine. Of course, as I said before, we are missing some details from your error message that would help us figure out the problem. Please post the FULL error message so we can help you further.

    Layne
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic