I am using Java -7. I want some help cause i stuck, i have a list that i add values all the time but in the end i want get the latest 15. The list handles DonateTable class that contains .getTime() which return long (System.getCurrentMilliseconds)
and i want to use this value to get the latest top 15. So higher ms = latest value. But idk how. This is my code
public ArrayList<DonateTable> getLog(int objectId)
{
ArrayList<DonateTable> data = new ArrayList<>();
for (DonateTable dt : list)
if (dt.getObjectId() == objectId)
data.add(dt);
return data;
}
public static class DonateTable
{
int _objectId = 0;
String _service = "";
long _time, _points = 0;
public DonateTable(int ObjectId, String service, long time, long points)
{
_objectId = ObjectId;
_service = service;
_time = time;
_points = points;
}
public int getObjectId()
{
return _objectId;
}
public String getService()
{
return _service;
}
public long getTime()
{
return _time;
}
public long getPoints()
{
return _points;
}
}