I`m currently trying to code a calender. I save my Appointments in 2 different ArrayLists within another ArrayList.
Strings ( Subject, Place, People ) go into the first ArrayList within another ArrayList = arStr
Integers( Date and Time ) go into the second ArrayList within another ArrayList = arInt
When I create an Appointment I want to sort it according to the date. So if I want to add a new Appointment, it should be saved above or below the saved ones ( depeding on the time ) in the outter List. The already saved ones should go down in the outter List, if their date is later than the new one. After that is done i want to connect the String Appointment to the Int Appointment.
My Problem is that I cant find a way to sort them in this way, can anyone help me 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 ?
}
}