I have a class called:
public class NXTCommAndroid implements NXTComm
Eclipse gives the following red error
The type NXTCommAndroid must implement the inherited abstract method NXTComm.search(String)
the IDE suggests to either make the class abstract, which is wrong, or to add unimplemented methods, which seems straight forward, except the method is already implemented.
It adds this:
//@Override
public NXTInfo[] search(String name) throws NXTCommException {
// TODO Auto-generated method stub
return null;
}
but this already exists as:
public NXTInfo[] search(String name, int protocol) throws NXTCommException {
//stuff that would take up too much room
}
You need to override the exact same method with the exact same method signature. That means: Same name, same return type, same scope (public, protected, private, none) and the same parameter types and number.
So your second method public NXTInfo[] search(String name, int protocol) throws NXTCommException
does not count as an override for public NXTInfo[] search(String name) throws NXTCommException
.
You might consider doing something like this:
@Override
public NXTInfo[] search(String name) throws NXTCommException {
return search(name, myDefaultProtocolInt);
}
public NXTInfo[] search(String name, int protocol) throws NXTCommException {
//stuff that would take up too much room
}