Can one create an array of calendar objects?
If yes, how does one do so? This code surely gives error
Calendar cal[length];
//loop for initialising all the objects in cal[] array
If no, what other way is there for getting “n” number of calendar objects?
I need this for a repeating alarm, set at different times.
You can always do
Calendar[] cal = new Calendar[length];You can use an ArrayList, too, such as:
List<Calendar> list = new ArrayList<Calendar>();Then there’s a lot of convenience methods, such as
add(Calendar calendar);Then:
You can use
for (int x = 0; x < list.size(); x++)or
for (Calendar cal : list)This is valid for the array, too. Inside the for you use
getCalendar()ornew GregorianCalendar()or whateverCalendaryou need.