title: For Each Infinite Loop
body: <p>I'm a beginner programmer and I  have created a method that takes user input in a string, checks whether it is an integer or a character, converts it and then passes it onto the next part of the method which is a for each loop which checks the id values of instances of the Person object stored in a linked list. </p>
  
  <p>However it is creating an infinite loop and I do not know how to break it so that it only outputs once. Any assistance is greatly appreciated. </p>
  
  <p>I've only included what I beleive to be the problem method, if you need more parts of the program please let me know and I will add it.</p>
  
  <pre><code>public void theSiv() {
          System.out.println("Please enter client Id:");
          String s = In.nextLine();
          boolean isValidInteger = false;
          char choice = 'p';
          boolean exists = false;
          int searchid = 0;
          try
          {
              int i = Integer.parseInt(s);
              isValidInteger = true;
              searchid = i;
          }
          catch (NumberFormatException ex)
          {
              choice = s.charAt(0);
          }
  
          while (choice !='x'){
              for (Person b:clients)
                  if  (b.getId() == searchid){
                      exists = true;
                      System.out.println("found client");}
  
              if(exists == false)
                  System.out.println("  No such client");
          }
  
      }
  </code></pre>