| | |
Interface ... extends ... implements ... (Need help)
![]() |
•
•
Join Date: Oct 2006
Posts: 11
Reputation:
Solved Threads: 0
Its been years since I've used Java, this one is stumping me...
I implemented my own Observer/Observable interfaces for use with a 2-way RMI setup(I'm sure theres a better name but I don't know it yet).
I have 2 interfaces ToyStore and ToyFactory. ToyStore extends Remote implements Observer, ToyFactory extends Remote implements Observable. I then have a Server class that implements ToyFactory and a Client class that implements ToyStore(I won't post the code for these 2 yet, I don't think its the problem but if need be I can post).
This is what I get when I compile:
Observer.java
Observable.java
ToyStore.java
ToyFactory.java
Am I compiling this wrong? Am I allowed to extend and implement in an interface? Does extending Remote block me from Implementing Observer/Observable? Missing semicolon? Let me know if I need to post the other 2 files...Thanks for the help.
I implemented my own Observer/Observable interfaces for use with a 2-way RMI setup(I'm sure theres a better name but I don't know it yet).
I have 2 interfaces ToyStore and ToyFactory. ToyStore extends Remote implements Observer, ToyFactory extends Remote implements Observable. I then have a Server class that implements ToyFactory and a Client class that implements ToyStore(I won't post the code for these 2 yet, I don't think its the problem but if need be I can post).
This is what I get when I compile:
Java Syntax (Toggle Plain Text)
$ javac -d ./test Client.java Server.java Observable.java Observer.java ToyFactory.java ToyStore.java ToyFactory.java:7: '{' expected extends Remote ^ ToyStore.java:7: '{' expected extends Remote ^ 2 errors
Java Syntax (Toggle Plain Text)
package toys; public interface Observer { public void update(Observable o); }
Java Syntax (Toggle Plain Text)
package toys; public interface Observable { public void addObserver(String s); }
Java Syntax (Toggle Plain Text)
package toys; import java.rmi.Remote; import java.rmi.RemoteException; public interface ToyStore extends Remote implements Observer { String sayHi() throws RemoteException; public void update(Observable o) throws RemoteException; }
Java Syntax (Toggle Plain Text)
package toys; import java.rmi.Remote; import java.rmi.RemoteException; public interface ToyFactory extends Remote implements Observable { String sayHello() throws RemoteException; public void addObserver(String s) throws RemoteException; }
An interface cannot implement anything, since an interface is not an implementation. An interface can only extend interfaces (exactly one).
Edit:
PS If you are a David Eddings fan, it is spelled Belgarath not Balgarath. If not, then please ignore.
Edit:
PS If you are a David Eddings fan, it is spelled Belgarath not Balgarath. If not, then please ignore.
Last edited by jwenting; Nov 6th, 2007 at 12:49 pm. Reason: PS it's implementation, not implementattion, and you instead of you
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Last edited by masijade; Nov 6th, 2007 at 2:29 pm.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Interface Expected Error (Java)
- CD Collection Almost there! (Java)
- Error in exception(RMI) (Java)
- actionPerformed and exceptions help? (Java)
- Datagrid to draw a table (C#)
- Playing with RMI in Tiger (Java)
- '[Class] is not abstract..' error when i use 'implements' (Java)
- JMF question: question about the unrealized player (Java)
Other Threads in the Java Forum
- Previous Thread: XML parsing issues - pls.help
- Next Thread: Rename directory in ant build script
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui html ide if_statement image inheritance integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list macintosh map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql static stop string swing threads transforms tree ui unicode validation windows






