|
You need a return in the third if statement,
otherwise the result from the recursive call to doSearch
is never propagated back up the call
stack.
public String doSearch(ListNode node,String
airportCode) {
if(node == null) { // if the node is null then // the list must be empty return("List is Empty\n"); } // end if if (node.airport.equals(airportCode) == true) { System.out.println("They are equal"); // debug System.out.println(node.airport); // debug return("Found: " + node.airport); } // end if if (node.link != null) { // if the node's link isn't null then // this isn't the last node so search ===> return doSearch(node.link, airportCode); // again with the link as the first node } // end if // if it hasn't met the first 3 requirments return ("Could not find: " + airportCode); // then the value isn't in the list. } // end doSearch
|
- [JAVA3D] A regular Java problem eb
- Re: [JAVA3D] A regular Java problem eb
- Re: [JAVA3D] A regular Java problem Kyle Wayne Kelly
- [JAVA3D] UI with Java3D Pedro Estrada
- [JAVA3D] UI with Java3D Firas MOHAMED
