我正在处理此代码以接收目标String并搜索目标的链接列表并删除它的所有实例。我觉得我有大部分逻辑,但我得到一个NullPointerException并需要一些帮助。这是代码:
public abstract class Viewer {
private String username;
private int level;
private int exp;
private int points;
private int intermediatePoints;
private boolean isMod;
private boolean isPreviousWinner;
private boolean enteredRaffle;
public Viewer(String username){
this.username = username;
this.level = 0;
this.exp = 0;
this.points = 0;
this.intermediatePoints = 0;
this.isMod = false;
this.isPreviousWinner = false;
this.enteredRaffle = false;
}
public Viewer(String username, int level, int exp, int points, int intermediatePoints,
boolean isMod, boolean isPreviousWinner, boolean enteredRaffle){
this.username = username;
this.level = level;
this.exp = exp;
this.points = points;
this.intermediatePoints = intermediatePoints;
this.isMod = isMod;
this.isPreviousWinner = isPreviousWinner;
this.enteredRaffle = enteredRaffle;
}
public String setViewerString(){
String viewerDataString = String.format("%s;%d;%d;%d;%d;%b;%b;%b;",
username, level, exp, points, intermediatePoints, isMod, isPreviousWinner, enteredRaffle);
return viewerDataString;
}
public void parseViewerDataString(){
}
}
}
答案 0 :(得分:-1)
您必须使用非空引用初始化当前和上一页!...
current = head;
prev = head;
但是head在构造函数中设置为null ...
current.getNext();
因为当前未初始化,这是一个空指针异常