eanCSE115 2018 ProblemSet zhengtao 0008,java- Eclipse Window Help JMobleset-zh ?
ID: 3740720 • Letter: E
Question
eanCSE115 2018 ProblemSet zhengtao 0008,java- Eclipse Window Help JMobleset-zh ?? Algorithms lja. D ProblemSet zh. ProblemSet zh.. Prol roblem Seth bublic class ProblemSet_zhengtao 00080 "q1: Write a public static method naned q1 that takes no parameters and returns a new Arraylist of type Integer containing the values 10, 5, and 5. The order of these values * must be maintained 3 q2: Write a public static method named q2 that takes no parameters and returns à new 5 HashMap with keys of type Integer mapped 6 key-value pairs 171:40, 4:-16, 78:49, 4:9, 12:47) to value of type Integer containing the * q3: Write a public static method named q3 that takes no parameters and returns a new : HashHap with keys of type Integer mapped to values of type Integer containing the s key-value pairs (94:46, 82:-1, 31:-3) 26/ 27 316 q4: Write a public static method named q4 that t Arraytist of type " "total". The order of these values must be maintained akes no parameters and returns a new String containing the values "table, "straw", "county", "towel", and Problems Javadoc Declaration o consoles to display at this time. ConsoleCoverage Writable DOLLExplanation / Answer
import java.util.ArrayList;
import java.util.HashMap;
public class ProblemSet{
public static ArrayList<Integer> q1 () {
ArrayList<Integer> list = new ArrayList<>();
list.add(10);
list.add(5);
list.add(5);
return list;
}
public static HashMap<Integer, Integer> q2 () {
HashMap<Integer, Integer> map = new HashMap<>();
map.put(71, 40);
map.put(40, -16);
map.put(78, 49);
map.put(40, 49);
map.put(12, 47);
return map;
}
public static HashMap<Integer, Integer> q3 () {
HashMap<Integer, Integer> map = new HashMap<>();
map.put(94, 46);
map.put(80, -1);
map.put(31, -3);
return map;
}
public static ArrayList<String> q4 () {
ArrayList<String> list = new ArrayList<>();
list.add("table");
list.add("straw");
list.add("country");
list.add("towel");
list.add("total");
return list;
}
}
Please rate my answer!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.