This is a noob question, sorry, but I am totally confused.
I had created a class called CalendarItems
.
The fields are:
int index
String description
String textdate
int daysaway
The constructor uses the first three fields. And for the moment I have created four objects within the class.
I now want to do two things:
- Loop through the CalendarItem's For each CalendarItem calculate daysaway, which is the difference between the text date and today. I have figured out how to calculate this and can manually add do it by calling my method for item1, then for item2, etc
But i'd like to understand how i can do this with a loop. If i was in javascript i'd have an multi-dimensional array and could easy create a loop to cycle through it, but in the scary new world of java I am lost
- Sort my
CalendarItems
on thedaysaway
field I want to do this so that I can display them as CardViews in order of soonest-first.
[Inflating CardViews
has proved blissfully straight-forward, and I can (again, with a manual 'loop') inflate a card for each CalendarItem
and add the various fields to it. And creating the class and fields and adding my 4 sample objects has also worked, so it hasn't been a total lost weekend.]
I think where I am going wrong is that I keep thinking in terms of multi-dimensional arrays from my experience with javascript and Excel VBA, and however much I read about objects and iterator interfaces and arraylists in java, my brain is just refusing to take it in.
I have Google'd a lot on this, but every 'simple guide to iterators' has left me more confused than when I started.
Thanks in advance to anyone patient enough to help me.