Beginning JSP Web Development - Ch08
Hello Everybody!
First, I'm really sorry but my English is not so good.
Well, I have two classes, User.java and ArrayListDemo.java, when I compile the second class (after compile the first class perfectly)I get this warning:
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
userlist.add(usr3);
/
What's the problem? Why can't I add my object usr3?
Can Anyone help me? Thanks!!!
User.java
package com.wrox.utilities;
public class User {
private String username;
private String phonenumber;
public String getUsername() {
return username;
}
public void setUsername(String uname) {
this.username = uname;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String pnumber) {
this.phonenumber = pnumber;
}
public User(){
}
public User(String uname, String pnumber){
this.username = uname;
this.phonenumber = pnumber;
}
}
ArrayListDemo.java
package com.wrox.utilities;
import java.util.ArrayList;
public class ArrayListDemo {
/* método estatico MAIN */
public static void main(String[] args) {
User usr1 = new User("J Smith", "123-444-4444");
User usr2 = new User("M Walker", "123-555-5555");
User usr3 = new User("R Johnson", "123-666-6666");
ArrayList userlist = new ArrayList();
userlist.add(usr3);
System.out.println("USERS LIST:");
for (int i=0; i<userlist.size(); i++){
User usr = (User) userlist.get(i);
System.out.println("User name: " + usr.getUsername());
System.out.println("Phone Number: " + usr.getPhonenumber());
}
}
}
|