Try code below :
public class Passenger
{
String name;
String address;
int age;
public Passenger(String n, String add, int a)
{
name = n;
address = add;
age = a;
}
public int getAge()
{
return age;
}
public String getAddress()
{
return address;
}
public String getName()
{
return name;
}
public void PrintList()
{
/*Passenger p1 = new Passenger();
p1.printList();*/
System.out.println("My name is" + name);
System.out.println("My address is" + address);
System.out.println("My age is" + age);
}
public static void main(String[] args)
{
/*Traveller[] travellerlist = new Traveller[3];*/
Passenger[] travellerlist = new Passenger[3];
travellerlist[0] = new Passenger("Jim","London",48);
travellerlist[1] = new Passenger("Sue","Manchester",22);
travellerlist[2] = new Passenger("Matt","Bristol",31);
for (int i =0; i<3; i++)
{
travellerlist[i].PrintList();
System.out.println ("==========================");
}
}
}