我對Java很新,所以我不明白爲什麼我會收到初始化錯誤。在代碼中,我的整數「Memes」表示它可能沒有被初始化,並且局部變量隱藏在字段中。變量未初始化並隱藏在字段中
private void totalUpdate(int yes){
if (yes==1){
int CompBot = Integer.parseInt(lblbotComp.getText());
int CompTop = Integer.parseInt(lbltopComp.getText());
int CompMid = Integer.parseInt(lblmidComp.getText());
int Memes = Memes + CompBot + CompTop + CompMid;
lbltotalComp.setText("Computer has earned "+ Memes +" points in total");
}
}
private void pointUpdate(int points){
pointsUser = pointsUser + points ;
lbluserPointsEst.setText (""+pointsUser+"");
}
private void computerPointUpdate(int pointComp){
pointsComputer = pointsComputer + pointComp ;
lblcompPointsEst.setText (""+pointsComputer+"");
}
private int play(int points){
int score;
int randomScore = (int)((100 -1 +1)*Math.random() +1);
if (randomScore < points){
score = points;
}
else{
score = 100;
}
return score;
}
private int playComp(int pointsComp){
int score;
int randomScore = (int)((100 -1 +1)*Math.random() +1);
if (randomScore < pointsComp){
score = pointsComp;
}
else{
score = 100;
}
return score;
}
private int Memes = 0;
private final Timer messageTimer;
private int pointsComputer = 0;
private int pointsUser = 0;
private int count;