title: How to break loops and assign parameters to array object
body: <ol>
  <li>The loop should stop if I enter other numbers but it still looping.</li>
  <li>There is an error to set information to the employee object. How actually it is supposed to write?</li>
  </ol>
  
  <pre class="lang-java prettyprint-override"><code>System.out.println("Enter '1' to add employee's information:");
  
  int add = s.nextInt();
  
  while(add==1){
  
     for (int i=0; i&lt;=employees.length; i++){
  
         System.out.println("Enter the name :");
         String newName = s.next();
  
         System.out.println("Enter the IC number :");
         String newIC = s.next();
  
         System.out.println("Enter the department :");
         String newdept = s.next();
  
         employees[i] = new Employee();
         employees[i].setEmployee(newName, newIC, newdept);
  
         System.out.println("Enter '1' to add employee's information:");
         add = s.nextInt();
       }
  }
  </code></pre>
  
  <p>the result is for the loop can stop and we can set information for the object.</p>