This loop is supposed to take a user inputted string, compare it to a string variable of another class that is stored in an array and if they're equal it is supposed to have the user edit the information and set the new variables. I can get it to exit, but after all of the new info is entered it just prompts the user for the information again. Any help would be greatly appreciated. Thanks
public static void changeData(Student [] x){ String sName=""; String newFirst; String newLast; String newPhone; double newGPA; String test=""; boolean same=false; Scanner input=new Scanner(System.in); System.out.println("Enter name of student you wish to edit: "); sName=input.nextLine(); for(int i=0;i<x.length;i++) { test=x[i].getName(); if(sName.equalsIgnoreCase(test)) { System.out.println("New data for student: "); System.out.println("Enter first name: "); newFirst=input.nextLine(); System.out.println("Enter last name: "); newLast=input.nextLine(); System.out.println("Enter new phone number: "); newPhone=input.nextLine(); System.out.println("Enter new GPA: "); newGPA=input.nextDouble(); x[i]=new Student(newFirst,newLast,newPhone,newGPA); break; } else { System.out.println("That name doesn't exit in our records"); break; } } }