This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Can I override an interface method in the class ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can I override an interface method in the class ?" Watch "Can I override an interface method in the class ?" New topic
Author

Can I override an interface method in the class ?

Sherry Jacob
Ranch Hand

Joined: Jun 29, 2005
Posts: 128
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


<strong><br />Cheers !!<br /> <br />Sherry<br /></strong><br />[SCJP 1.4]
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
Hi

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

bye for now
sat
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
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

Joined: Jul 11, 2001
Posts: 14112
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?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
 
subject: Can I override an interface method in the class ?
 
Similar Threads
anonymous class?
How to call a generic method with two bounds (for a single argument) if one bound needs a cast
Confusion
1 error when compiling PlayCode.java
Need a Solution about the code given?