Hi, I have two classes which extend interfaces. One extends Serializable, the other javax.ejb.EntityBean I do import the right packages. java.io.Serializable and javax.ejb.* Compiler complains: no interface expected here. I guess the solution is pretty straightforward, but I don't see what I'm doing wrong. thanks for setting this straight.
Originally posted by Peter Simon: Hi, I have two classes which extend interfaces. One extends Serializable, the other javax.ejb.EntityBean I do import the right packages. java.io.Serializable and javax.ejb.* Compiler complains: no interface expected here. I guess the solution is pretty straightforward, but I don't see what I'm doing wrong. thanks for setting this straight.
Yeah, Barry Gaunt is right, you have to use implement instead of extends interfaces in your case:
Volodymyr got in before me ( while I had to go for my books ) You must implement EntityBean. Damm... I'll just have to learn to type with four fingers... [ October 25, 2002: Message edited by: Barry Gaunt ]
Barry and Volodymyr, Maybe you can help me with this one aswell... I have to write a method which as an argument receives an object. The method has to check with instanceOf wether it is an object of a certain type,(in my case CabinPK)and if so check wether a variable of that object is equal to a variable from the class which implements the method equals. It seems that the object received as an argument has to be casted to CabinPK first before being able to compare variables. Would you know how to do this? Here is my code for what it is worth: public boolean equals(Object obj){ if(obj instanceof CabinPK == true) { if (obj.id == this.id){ return true ; {
>It seems that the object received as an argument >has to be casted to CabinPK first before being >able to compare variables. Once you have successfully tested the class of an object with intanceof, you can safely cast it with (classname)varname. Until you do so, the object is only an Object. It will behave as a CabinPK for just that call when you are casting it. If you want to make multiple calls to something, each require casting, you can use a local variable for help: