I'm a beginner in Java and I have a problem with printing duplicate rows. I have this code:
while (rs.next()) {
String curr_crn = rs.getString(2);
while(rs.next()) {
if(curr_crn != rs.getString(2)) {
String instructor = getInstructor(connection,
rs.getString(1),rs.getString(2));
String student = getStudent(connection,rs.getString(2));
detailLines.add(Library.rPad(rs.getString(1), COL1, ' ')
+ Library.rPad(rs.getString(2), COL2, ' ')
+ Library.rPad(rs.getString(3) + " " + rs.getString(4) +
" " +rs.getString(5), COL3, ' ')
+ Library.rPad(instructor, COL4, ' ')
+ newline
+ Library.rPad(student, COL1 ,' '));
}
}
}
How do I compare current crn
to the other crn
so that I won't print duplicates?
thanks!