저는 현재 캘린더를 코딩하려고합니다. 나는 다른 ArrayList 내에 2 개의 다른 ArrayList에 내 Appointments를 저장합니다.ArrayLists 사이의 Int를 비교하는 방법 ArrayLists?
문자열 (주제, 장소, 사람) 내가 약속 I를 만들 = arInt
다른 ArrayList를 내 두 번째의 ArrayList에 가서 다른 ArrayList를 = arStr
정수 (날짜 및 시간) 내에서 첫 번째의 ArrayList로 이동 날짜별로 정렬하고 싶습니다. 따라서 새로운 약속을 추가하고 싶으면, 그것을 외래 목록에있는 저장된 것의 위나 아래에 저장해야합니다 (시간이 지날수록). 날짜가 새 것보다 늦으면 이미 저장된 사람들은 outter List에서 내려야합니다. 그 후에는 Int 약속에 문자열 약속을 연결하고 싶습니다.
내 문제는 내가 이런 식으로 그들을 정렬 할 수있는 방법을 찾을 수있다, 아무도 나를 도와 줄 수 pls :)?
public class Calender
{
public static ArrayList<ArrayList<Integer>> arInt = new ArrayList<ArrayList<Integer>>();
public static ArrayList<ArrayList<String>> arStr = new ArrayList<ArrayList<String>>();
public static Scanner read = new Scanner(System.in);
public static int counter = 0; // counts all made appointments
public static void main (String[]args)
{
//Adding Arrylists for space
arInt.add(new ArrayList());
arStr.add(new ArrayList());
arInt.add(new ArrayList());
arStr.add(new ArrayList());
// This is one Appointment (Subject, Year, Month, Day, Hour)
// Already saved Appointment
counter++;
arStr.get(0).add("3.Liste");
arInt.get(0).add(2017);
arInt.get(0).add(2);
arInt.get(0).add(8);
arInt.get(0).add(16);
// new Appointment
counter++;
String betreff = "1. Appointment";
int year = 2017;
int month = 2;
int day = 8;
int hours = 15;
// How to compare these Variables with the first Appointment and save it accordigly ?
}
}
기본적으로 나는 단지 하나의 ArrayList thats가 Appointments로 구성되어 있을까요? Thx 당신의 도움! – Coldvirus
그냥 제안. 물론 실제 실제 Calendar 구현은 훨씬 더 복잡 할 수 있습니다. 그러나 당신의 업무가 몇몇 약속을 저장하는 것이라면, 그렇습니다, 나는 그렇게 할 것입니다. – Halmackenreuter
변경 사항이 있는지는 모르겠지만 모든 작업에는 약속 삭제, 약속 변경, 예 : 'D – Coldvirus