Given the following code:
for (int i = 0; i < noRooms; i++) {
String roomPrice = response.xmlPath().getString("ABC_AvailRS.AccommodationSearchResponse.Accommodations.AccommodationSegment[0].AccommodationUnits.AccommodationUnit[" + i + "].RoomRate.@Amount");
roomPrices.add(roomPrice);
List<Float> floatRoomPrices = roomPrices.stream()
.map(Float::parseFloat)
.collect(Collectors.toList());
float min = floatRoomPrices.stream().min(Float::compare).get();
float max = floatRoomPrices.stream().max(Float::compare).get();
}
...in which I can grab a list of amounts as Strings Amount="92.65", convert them to floats and add to a List, I can clearly find the highest and lowest amount.
- how can I get the mid point value of floatRoomPrices?
- how can I find it's position within the List e.g. [4] if it was the mid range of 10 float values?