MediaSignage support forum

community support => Report bugs and errors => Topic started by: debicavett on August 24, 2010, 02:14:57 AM

Title: Java problem! Why do I get this error? Could anyone please help remove the bug :
Post by: debicavett on August 24, 2010, 02:14:57 AM
warning: [unchecked] unchecked call to add(E) as a member of the raw type
java.util.ArrayList

Here is my code...

import java.util.*;

class Emp {

public Emp(String n, double s, int year, int month, int day) {
name = n;
salary = s;
GregorianCalendar calendar = new GregorianCalendar(year, month - 1, day);
hireDay = calendar.getTime();
}

public String getName() {
return name;
}

public double getSalary() {
return salary;
}

public Date getHireDay() {
return hireDay;
}

public void raiseSalary(double byPercent) {
double raise = salary * byPercent / 100;
salary += raise;
}

private String name;
private double salary;
private Date hireDay;
}


import java.util.*;

public class TestArrayList {

public static void main(String[] args) {

ArrayList staff = new ArrayList();

staff.add(new Emp("Raj", 20000, 2005, 9, 14));
staff.add(new Emp("Deep", 35000, 2009, 12, 5));
staff.add(new Emp("Mr. Rai", 50000, 2011, 1, 13));

for(int i = 0; i < staff.size() ; i++) {
Emp e = (Emp) staff.get(i);
e.raiseSalary(5);
}

for(int i = 0; i < staff.size(); i++) {
Emp e = (Emp) staff.get(i);
System.out.println("Name: " + e.getName()
+ " Salary: " + e.getSalary()
+ " Hire day: " + e.getHireDay());
}
}
}




Thanks Mark for your help! It worked :)