I suppose you should end up with an array of Avengers.
Try, for instance:
public class Avenger
{
String name , weapon,planet;
int age , power;
public Avenger(String name, String weapon, String planet,int age, int power )
{
this.name = name;
this.weapon = weapon;
this.planet = planet;
this. age = age;
this.power = power;
}
public void displayDetails()
{
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Power: " + power);
System.out.println("Weapon: " + weapon);
System.out.println("Planet: " + planet);
}
public static void main( String arg[])
{
Avenger [] avenger = AvengerFactory.getAvengers();
for (Avenger a : avenger)
{
a.displayDetails();
System.out.println();
}
}
}
class AvengerFactory
{
final static int Avengers = 5;
final static String[] name = {"Iron Man","Captain America","Thor","Black Widow","Hulk"};
final static String[] weapon = {"Repulsor","Shield","Stormbreaker","Baton","Mjolnir"};
final static String[] planet = {"Titan","Earth","Asgard","Vormir","Sakaar"};
final static int[] age = {48,27,1500,34,58};
final static int[] power = {9,10,20,6,8};
static Avenger [] s_avenger = null;
public static Avenger[] getAvengers()
{
if ( s_avenger == null )
createAvengers();
return s_avenger;
}
static void createAvengers()
{
s_avenger = new Avenger[Avengers];
for (int i=0; i<Avengers; ++i)
{
s_avenger[i] = new Avenger(name[i], weapon[i], planet[i], age[i], power[i]);
}
}
}