• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I override an interface method in the class ?

 
Sherry Jacob
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a simple code here:



What I wanna know is, can I override the identify method in this way ? If not, then what's the way 2 override the identify() method in the class ?

Please help.
Thanx
 
satishkumar janakiraman
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You cannot. But You can use the same method with different signature in your class

bye for now
sat
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Java Tutorial:
Unlike a class, an interface never implements methods; instead, classes that implement the interface implement the methods defined by the interface.

An interface does not have concrete methods, so you cannot override them.
[ July 27, 2005: Message edited by: Steve McCann ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sherry Jacob:
What I wanna know is, can I override the identify method in this way? If not, then what's the way 2 override the identify() method in the class ?


What you are trying to do is not overriding, but defining the same method twice in the same class.

Can you please explain what you are trying to do, and why? What are your requirements?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic