Here is my program
String thisSchool=buffer.readLine();
String thisLine;
while((thisLine = buffer.readLine()) != null){
if(thisLine=="*")
{
thisSchool=buffer.readLine();
}
else
{
School school = new School(thisSchool);
Student student = new Student(thisLine, school);
StudentList.add(student);
}
}
My text file reads like this:
School1
A
B
C
*
School2
D
E
*
School3
F
The output of my driver class is:
A School1
B School1
C School1
* School1
School2 School1
D School1
E School1
* School1
School3 School1
F School1
This is what I WANT it to look like
A School1
B School1
C School1
D School2
E School2
F School3
Here's what the problem looks to be The "currentSchool" variable is never changing, and I don't know why! The " * " is treated as a student (I want to use it as a delimiter, i.e., the program will ignore it when it is encountered). Instead, the "if line= * " command is being ignored completely, and consequently, the school never changes, and the students are being written incorrectly