我试图将多个单项插入ArrayList> 这是我的代码:
public static ArrayList<HashMap<String, String>> alarmClocks = new ArrayList<>();
public void q1() {
int[] multipleHours = {9, 11, 13, 14, 15, 17, 18}; //store here the hours for every alarm you want to set
int[] multipleMinutes = {45, 0, 0, 0, 45, 0, 45}; //store here the minutes
String[] multipleDestinations = {"Departure", "Quezon Heritage House", "Art In Island", "Quezon City Experience", "Quezon Memorial", " Destination 5", "Destination 6"}; //same thing for destinations
String[] multipleReminders = {"You need to go to Destination 1", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Timeout, Go to next destination", "Package Ended!"}; //and reminders
HashMap<String, String> alarm = new HashMap<>();
alarm.put(ApplicationConstants.HOUR, String.valueOf(multipleHours));
alarm.put(ApplicationConstants.MINUTE, String.valueOf(multipleMinutes));
alarm.put(ApplicationConstants.REMINDER, String.valueOf(multipleReminders));
alarm.put(ApplicationConstants.DESTINATION, String.valueOf(multipleDestinations));
alarmClocks.add(alarm);
}
插入应该是这样的:
项目1:9 - 45 - 出发 - 你需要去目的地1
项目2:11 - 0 - 奎松遗产屋 - 超时,前往下一个目的地。
我的问题是代码包含数组中的所有项目
错误提示如下:
java.lang.NumberFormatException: Invalid int: "[9, 11, 13, 14, 15, 17, 18]"
答案 0 :(得分:0)
尝试接受循环:
+retrieveEnsembleIdentifiersFromCloudFileSystem:completion:
但请记住所有数组长度应相同,否则会产生indexoutofbound错误。