Hi guys how does one index an object with a collection in an ArrayList,the code i used reports an error."expected is an array and found is an array list" and the possible loss of precision error.this is the code
while(inFile.ha sNext())
{
for(Worker worka : badiri){ //fills up the collection with worker objects
badiri.add(new Worker(workerNa me,salaryRate)) ;
}
badiri.sort(); //sorts the collection
for(int j= 0; j< badiri.length;j ++){ //computes the sum of the salary rates all the workers
sum+= worka.getSalary Rate();
}
median = sum/badiri.length; //computes the median salary rate
//output
System.out.prin tln("Smallest Salary Rate= " + badiri[0].toString());
System.out.prin tln("Median Salary Rate= " + badiri[median].toString());
System.out.prin tln("Largest Salary Rate= " + badiri[badiri.length-1].toString());
}//close while loop #2
while(inFile.ha sNext())
{
for(Worker worka : badiri){ //fills up the collection with worker objects
badiri.add(new Worker(workerNa me,salaryRate)) ;
}
badiri.sort(); //sorts the collection
for(int j= 0; j< badiri.length;j ++){ //computes the sum of the salary rates all the workers
sum+= worka.getSalary Rate();
}
median = sum/badiri.length; //computes the median salary rate
//output
System.out.prin tln("Smallest Salary Rate= " + badiri[0].toString());
System.out.prin tln("Median Salary Rate= " + badiri[median].toString());
System.out.prin tln("Largest Salary Rate= " + badiri[badiri.length-1].toString());
}//close while loop #2
Comment