Help me please - simple program
I have a problem with the NullPointerException: null in this programe and the sorting method is not working.
Anyone please help me to solve that problem. Because 5 hours left I have to submit this program.
The source code is here. I am using BlueJ to write the code.
http://files-upload.com/325815/LabTest1.zip.html
Thank You
[357 byte] By [
Triagipa] at [2007-11-27 8:55:02]

this code is to sort the data and display the sorted data in the JTable.
public void sortProgram() {
Subject sb[] = new Subject[subjects.size()];
for(int i = 0; i < subjects.size(); i++)
sb[i] = (Subject)subjects.get(i);
for(int i = 1; i < subjects.size(); i++)
for(int j = 0; j < subjects.size() - 1; j++) {
if(((sb[j].getProgram()).compareTo(sb[j + 1].getProgram())) > 0) {
Subject cache = sb[j];
sb[j] = sb[j + 1];
sb[j + 1] = cache;
}
}
Vector col = new Vector();
Vector row = new Vector();
Vector rows = new Vector();
col.add("Program Code");
col.add("Course Code");
col.add("Subject Title");
for(int i = 0; i < subjects.size(); i++)
sb[i] = (Subject)subjects.get(i);
for(int c = 0; c < sb.length; c++) {
row.add(sb[c].getProgram());
row.add(sb[c].getCourse());
row.add(sb[c].getSubjectTitle());
rows.add(row);
row = new Vector();
}
> 1. What line throws the NPE?
>
> 2. Why not use a sorting method in the API?
1. The problem is the data is not sorted. and the NPE is in another method, not in this method.
2. I also want to use method in the API, but the lecturer expect that kind of sorting method.