I am trying to take a String from a JTextField using getText and apply it to the method
SearchString but i am presented with the error Incompatible Types i cannot see anything wrong with this code however.
ActionListner code:
String whatToSearch,result
JTextField searchfield
method SearchString
EDIT: have changed to Public String, but i am now given a Missing Return Statement error at the line shown above
The compilation error is saying that you can’t assign the result of
SearchString(whatToSearch)toresult. This is becauseSearchStringis declared to return NO result; that’s whatvoidmeans!The fix is to change the signature to
public String SearchString(String input) ...and change the body to return a String value at the appropriate point or points.