Hi All,
I dont very well understand how exactly do i create a array of type object. Below i will paste what i am trying to do, so that you have a good idea of what i am talking about.
Thanks
package Person;
public class PersonTest
{
static Person[] p;
public PersonTest()
{
p=new Person[3];
}
public void insert()
{
for(int i=0;i<(p.length-1);i++)
{
p[i].name="i";
p[i].ID=i;
}
}
public void display()
{for(int i=0;i<(p.length-1);i++)
{
System.out.println(p[i].name);
System.out.println(p[i].ID);
}
}
public static void main(String[] args)
{
PersonTest t = new PersonTest();
t.insert();
t.display();
}
}
package Person;
public class Person
{
String name;
int ID;
public Person()
{
}
}