I want to check whether a patient object already exists in an ArrayList queue using the unique ID nhsNumber. But when I add a patient to the queue who I know already exists in the queue, the following code does not detect it. Any idea why this is?
public boolean checkIfInQueue(Patient p) {
    // set nhsNumber equal to the nhsNumberLabel on the page
    String nhsNumber = nhsNumberLabel.getText();
    System.out.println("Checking if " + nhsNumber + " already in the queue");
    // create boolean to state whether a person is in the queue or not (defaults to false)
    boolean isInQueue = false;
    for (int i = 0; i < Queue.queue.size(); i++) {
      if (Queue.queue.size() == 0) {
        System.out.println("Queue is empty");
        isInQueue = false;
        break;
      } else if (Queue.queue.get(i).getNhsNumber() == p.getNhsNumber()) {
        System.out.println(p.getFirstName() + " is already in the queue (checkIfInQueue() method)");
        isInQueue = true;
        break;
      } else {
        System.out.println(p.getFirstName() + " is not is the queue (checkIfInQueue() method)");
        isInQueue = false;
      }
    }
    return isInQueue;
  }
thanks, K
 
     
     
    