Question
Java programming Do the same question with List Array (list_to_map) class Plant { private String p_name; private String p_type; private String p_ordo; public void set_p_name(String
Java programming Do the same question with List Array (list_to_map)
class Plant {
private String p_name;
private String p_type;
private String p_ordo;
public void set_p_name(String s_name) { public String get_p_name() {
p_name = s_name; } return p_name; }
public void set_p_type(String s_type) { public String get_p_type() {
p_type = s_type; } return p_type;}
public void set_p_ordo(String s_ordo) { public String get_p_ordo() {
p_ordo = s_ordo; } return p_ordo;}
}
Write a method with the name "map_to_list that it should have two arguments maparr_plants (Map array of objects of a kind of class Plant, and keys are integer numbers), and listarr_plants (List array of objects of a kind of class Plant). This method should copy all elements of the maparr_plants into the empty array listarr_plants.
Solution:
public static void map_to_list(Map
List listarr_plants) {
Plant plant;
for (Map.Entry
plant=entry.getValue();
lisarr_plants.add(plant);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started