This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Interfaces and Implements
Posted by Eric Hardesty on July 13, 2000 at 4:43 PM
I can't. These are published spec interfaces from Sun for a connector that I'm building. I have also tried to add a clone() method in the MappedRecord class, but then I get errors because I have not implemented all the methods for java.util.Map also. > The spec for java.lang.Object lists clone() as a protected method. What happens if > you change your method signatures for clone() from public to protected? > > > I tried to implement an interface that I was given, but I continue to get the same error on the compile. I'm somewhat new to Java, but not programming. Can anybody explain what I need to do to fix this? > > Interfaces: > > package test; > > public interface Record extends java.lang.Cloneable { > > public > > Object clone() throws CloneNotSupportedException; > > } > > package test; > > public interface MappedRecord extends Record, java.util.Map { > > } > > Implementation: > > package works; > > public class Record implements test.Record { > > public > > Object clone() throws CloneNotSupportedException > > { > > Object o = null; > > try { > > o = super.clone(); > > } > > catch (CloneNotSupportedException e) { > > throw e; > > } > > return o; > > } > > } > > package works; > > public class MappedRecord implements test.MappedRecord { > > } > > I have tried including different methods into this class, but nothing works. Here is the message that the compile gives me: > > D:\jclasses\works>javac -classpath d:\jclasses -d d:\jclasses MappedRecord.java > > MappedRecord.java:3: The method java.lang.Object clone() declared in class java.lang.Object cannot override the method of the same signature declared in interface test.Record. The access modifier is made more restrictive.public class MappedRecord implements test.MappedRecord { > > ^ > > 1 error > > Thanks for any help. > > Eric
Replies:
|