i try to make an array of objects!

Asua / K53s
April 20, 2012 at 04:50:29
Specs: Windows 7, 2GH
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Arrays;
import java.lang.String;
import java.lang.NullPointerException;

public class phonebook
{
private static int i=0;
static personinfo[] perinf;
public phonebook()
{
perinf=new personinfo[2];
}
//public void addanew(String name1,Integer phnum1)
//{
/*perinf[i].name.add(name1);
perinf[i].phnum.add(phnum1);
i++;
System.out.println("unsorted information are:");
for(int j=0;j<5;j++)
{
System.out.println(""+perinf[i].name.get(j));
System.out.println(""+perinf[i].phnum.get(j));
*/
//}


public static void main()
{
//perinf[0].name=new ArrayList();
perinf[0].name.add("ali");
System.out.println(""+perinf[0].name);
//perinf[0].phnum=new ArrayList();
perinf[0].phnum.add(012);
System.out.println(""+perinf[0].phnum);
//perinf[1].name=new ArrayList();
perinf[1].name.add("nilo");
System.out.println(""+perinf[1].name);
//perinf[1].phnum=new ArrayList();
perinf[0].phnum.add(456);
System.out.println(""+perinf[1].phnum);
}
}


See More: i try to make an array of objects!

Report •


#1
April 20, 2012 at 08:03:07
Hi there,

1. A class name should start with a capital : Phonebook not phonebook.
2. Your description is not very clear - are you using Object objects or some other kind of object (e.g. Person)
3. Please post all your error messages, your code looks unorthodox to say the least ;-)

Thanks

Elinor Hurst
http://elinorhurst.blogspot.com


Report •
Related Solutions


Ask Question