As part of my studies on java I'm trying to create a search function, which takes in one parameter String key that correlates to a destination of an object Plane.
Before that I create a Queue of 20 Object each with different parameters and am now trying to search by destination.
This is what I have so far:
    public Plane searchDestination(String key)
    {
        Plane current = first;
        while(current.destination != key)
        {
            if(current.next == null)
                return null;
            else
                current = current.next;
        }
        return current;
    }
It returns successful build, but doesn't return an object(s) with matching criteria, I tried adding System.out.println(current); after return current; but compiler throws out an error. I also have a .displayPlane(); function that should display all plane details (and works in other cases), but when I add current.displayPlane(); after my return current; I get an error saying that it is unreachable.
Am I doing the search correctly, or am I missing something out?
 
     
     
    