私は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;