【发布时间】:2018-01-05 23:27:00
【问题描述】:
我正在尝试将多个单个项目插入 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 - Quezon Heritage House - 超时,前往下一个目的地。
我的问题是代码包含数组中的所有项目
错误提示如下:
java.lang.NumberFormatException: Invalid int: "[9, 11, 13, 14, 15, 17, 18]"
【问题讨论】:
标签: android string arraylist hashmap