its not compiling plz check it ?

note:AddressBook.java uses unchecked or unsafe operation

note:recompile with -Xlint :unchecked for details

is the error in the following code plz solve this problem for me

import javax.swing.*;

import java.util.*;

public class AddressBook

{

private ArrayList persons;

public AddressBook()

{

persons=new ArrayList();

}

public void add()

{

String s1=JOptionPane.showInputDialog("enter the Name please");

String s2=JOptionPane.showInputDialog("enter the Address please");

String s3=JOptionPane.showInputDialog("enter the Phone Number please");

PersonInfo p=new PersonInfo(s1,s2,s3);

persons.add(p);

}

public void searchByName(String n)

{

for(int i=0;i<persons.size();i++)

{

String s1=JOptionPane.showInputDialog("enter the Name to be search please");

PersonInfo p=(PersonInfo) persons.get(i);

String g=p.getname();

if (g.equals(n))

{

p.print();

}

}

}

public void delete()

{

String s1=JOptionPane.showInputDialog("enter the Name to be deleted please");

for(int i=0;i<persons.size();i++)

{

PersonInfo p=(PersonInfo) persons.get(i);

String g=p.getname();

if (g.equals(n))

{

persons.remove(i);

}

}

}

}>

[1400 byte] By [razaa] at [2007-10-3 2:41:57]
# 1
That's a warning and not an error, so the code compiles.Kaj
kajbja at 2007-7-14 19:40:40 > top of Java-index,Java Essentials,New To Java...
# 2

You can improve this code to take advantage of generics, a new feature available as of Java 5 to improve compile-time type checking.

By declaring your ArrayList as ArrayList<PersonInfo> (and also creating it as such), you basically tell the compiler: I will only store PersonInfo objects in this list, and the compiler will check that for you.

You can then get rid of the casts when getting objects out of the list.

This will also get rid of the warnings.

Herko_ter_Horsta at 2007-7-14 19:40:40 > top of Java-index,Java Essentials,New To Java...