Ask Question
11 June, 20:54

Write a public static method called createParty that has one parameter of type String[] called names containing the Pokemon names, followed by a parameter of type int[] called levels containing the Pokemon levels (where names[i] and levels[i] are the name and level of Pokemon i in the party). It should return the party as a ArrayList> as described above

+3
Answers (1)
  1. 11 June, 23:38
    0
    public static ArrayList createParty (String[] names, int[] levels)

    {

    ArrayList party = new ArrayList (6);

    for (int i=0; i<6; i++) {

    HashMap hm = new HashMap ();

    hm. put ("Name", names[i]);

    hm. put ("Level", levels[i]);

    party. add (hm);

    }

    return party;

    }

    Explanation:

    If the Sample data below is typed when the code above is executed

    Beedrill Venasaur Charizard Blastoise Butterfree Weedle

    88 84 84 84 80 82

    The expected Output will be:

    Beedrill 88

    Venasaur 84

    Charizard 84

    Blastoise 84

    Butterfree 80

    Weedle 82
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a public static method called createParty that has one parameter of type String[] called names containing the Pokemon names, followed ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers