(Scanner Input=new Scanner(System.in))
I have a while loop in my program with Input.hasNext() condition.
I want to read a line with scanner without Input.nextLine(); because i want to use the strings and integers in that line with .next() & .nextInt() ,how can i break the while loop after reading one line, or how can I break the while loop with entering newline character?
while (Input.hasNext()) {
if (Input.hasNextFloat()) {
Grade=Input.nextFloat();
P.setGrades(Grade);
j=0;k=1;
continue;
}
if (k==1) {
P.getGPA();
P=new Person();
k=0;
}
if (j==1) {
P.setLastName(Input.next());
continue;
}
P.setFirstName(Input.next());
i++;
j=1;
}
if you only want 1 line read in 1 line and then parse the line