I have a method public int bar()
, where i have declared an int total
(in the method body ofc). So this should be a simpel local variable, the thing is that eclipse complain about
Description Resource Path Location Type
The local variable total may not have been initialized Repository.java /proj_individual/src/repo line 35 Java Problem
general example :
public int foo(){
int total;
for(... : ...){
total += 1; // complains
}
return total;// complains
}
and my exact code:
public int getLocatars(){
int total;
for ( Map.Entry<Apartment, List<Expense>> entry : dic.entrySet() ) {
if(entry.getKey().isDebt()){
total += entry.getKey().getNrProple();
}
}
return total;
}
I have no idea what I may have done wrong, so any idea is helpful, thank you.