Hi Every body!
I'm trying to store (momently) each element of a ArrayList in a Programmer object variable to use one of its method, but I'm getting and and error and a warning I don't know neither why nor how to fix it
public double getBonusPay() { //bonus pay = base bonus * (1 - 0.01 * number of programmers that have overtime pay) double totalbonus = 0.00; int i; int numProgrammers = 0; Programmer proWithoverp; for(i = 0; i <= this.juniors.size(); i++){ proWithoverp = this.juniors.get(i); // <<============here is where I get the error, but I don't know why if(proWithoverp.getOvertimePay() > 0){ numProgrammers++; } if(numProgrammers <= 100){ totalbonus = getBaseBonus() * (1 - 0.01 * numProgrammers); } } return totalbonus; }
in the constructor I declared juniors as:
this.juniors = new ArrayList();
this is the error and the warning
javac -Xlint Test.java
./jac444b/a1/Manager.java:24: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
this.juniors.add(pgr);
^
./jac444b/a1/Manager.java:56: incompatible types
found : java.lang.Object
required: jac444b.a1.Programmer
proWithoverp = this.juniors.get(i);
^
1 error
1 warning