I have an array
of elements where each element is of type Map
How to find Minimum and Maximum of Keys of a Map<String,float>
My Code :
Please help.
May be you can use Comparator and you create ascending order value arraylist
public static ArrayList<ObjectA> getObjectAList() {
ArrayList<ObjectA> objectAList = new ArrayList<>();
Collections.sort(objectAList, ObjectA.objectAValue);
return objectAList;
}
public class ObjectA{
/* Comparator for sorting the list by value */
public static Comparator<ObjectA> objectAValue = new Comparator<ObjectA>() {
@Override
public int compare(ObjectA object1, ObjectA object2) {
float value1 = object1.getValue();
float value2 = object2.getValue();
/* For ascending order */
return Float.floatToIntBits(value1)-Float.floatToIntBits(value2);
}
};
}
I have an array
of elements where each element is of type Map
How to find Minimum and Maximum of Keys of a Map<String,float>
My Code :
Please help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.