Dear Members

I am having a problem in Java and I am pasting the code and the error message please tell me where is the problem and aslo tell me any directory that can guide me about frequent error messages and their solutions. here is the code.

import javax.swing.*;
import java.util.*;

public class PersonInfo{

String name;
String address;
String phoneNo;
String emailAddress;
String fatherName;

public PersonInfo(String n, String ad, String pn, String eml, String fn)


ArrayList person=new ArrayList();
public void print()

JOptionPane.showMessageDialog(null," Name "+name+" Address "+address+"Phone Number "+phoneNo+" Email Address "+emailAddress+"Father Name "+fatherName);


public void addPerson()

String nm=JOptionPane.showInputDialog("Please enter the name");
String add=JOptionPane.showInputDialog("Please enter the address");
String pno=JOptionPane.showInputDialog("Please enter the phone number");
String em=JOptionPane.showInputDialog("Please enter the email address");
String fth=JOptionPane.showInputDialog("Please enter the father name");

PersonInfo p=new PersonInfo(nm,add,pno,em,fth);



ERROR: uses unchecked or unsafe operations.
Recompile with Xlint:unchecked for details.

The following is the piece of code that is giving you the problem :-

ArrayList person=new ArrayList();

Since JDK 5.0 you have to specify what kind of Objects your ArrayList is going to store.
For ex in you case it appears to be objects of class "PersonInfo".

So your code would be modified as :-

ArrayList<PersonInfo> person=new ArrayList<PersonInfo>();

But the last time I checked the compiler only gave me a warning not an Error.

This article has been dead for over six months. Start a new discussion instead.