I am a beginner and was making a small program to practice what i have learnt. I was writing code to check the grade of a student.
This is the code :
import java.util.*;
public class Grader {
public static void main(String[] args) {
String studentName;
int rollNo = 0;
Scanner inputter = new Scanner(System.in);
System.out.println("Please enter the roll number of the student: ");
rollNo = inputter.nextInt();
System.out.println("Thank you. Now, please enter the student's name: " );
studentName = inputter.next();
for(int i=0; ; i++){
System.out.println("Please enter a valid examination type, i.e FA or SA: ");
String examType = inputter.next();
examType = examType.toUpperCase();
if(examType == "FA" || examType == "SA"){
break;
}
}
}
}
The problem I am facing is that even though I enter a valid examType, the For loop doesn't break.