Here\'s something that bothers me regarding Interfaces and classes.
I\'m trying to do an implemataion for an interface called IPAddress by a class named IPAddressString.
You can implement IPAddress
in IPAddressString
. Although you are implementing all the methods of IPAddress
interface in your IPAddressString
class, you are not telling this to the compiler [which clearly cannot guess your intentions].
change the definition of your class to :
class IPAddressString implements IPAddress
This should solve the problem in conversion.
Now this line:
IPAddress n1= new IPAddressString (n0,n1,n2,n3);
will not give you problems since the hierarchy is established. And you can peacefully return n1
.