I'm trying to select the first and last 25% of objects in a list and insert them into a second list. I've calculated the percentage and created a loop to select the first 25% of objects, but I can't figure out how to select the last 25% of objects in the list.
List<NodeObject> selectedNodes = new ArrayList();
//Calculate the percentage
double listLength = nodes.size();
double percentage = (listLength / 100) * 25;
int listQuarter = (int) percentage;
//Select first 25%
for (int i = 0; i < listQuarter; i++) {
NodeObject node = nodes.get(i);
selectedNodes.add(node);
}