Hi,
i get an NullPointerException in this line:if (let==currentLink.aLetter) in search method.
This is node class
public class Letter {
char aLetter;
int points;
Letter next;
public Letter(char aLetter,int points)
{
this.aLetter=aLetter;
this.points=points;
}
public Letter()
{
}
public String printLink() {
// System.out.print("{" + aLetter + ", " + points + "} ");
return aLetter+" "+points;
}
}
This is the other class
public class CardClass {
private Letter head;
// private Letter prev;
private static int size=0;
public CardClass()
{
head=new Letter();
//prev=new Letter();
}
//Returns true if list is empty
public boolean isEmpty() {
if (head == null)
return true;
else
return false;
}
public void insert(char aLetter, int points) {
Letter link = new Letter(aLetter,points);
if (size==0)
{
link.next=null;
head.next=link;
}
if (size>0)
{
link.next=head.next;
head.next=link;
}
size++;
}
public int getSize()
{
return size;
}
public void search(char let)
{
Letter currentLink = head.next;
int i=0;
while(i<size) {
if (let==currentLink.aLetter)
{
String str= currentLink.printLink();
Start ss=new Start();
javax.swing.JTextField jj= ss.getJTextField6();
jj.setText(str);
break;
}
currentLink = currentLink.next;
i++;
}
}
}
I dont unerstand why.
PLZ someone help me out.
cheers