Skip to content
Advertisement

Tag: sorting

How to use arrayList sort and manipulate the vlaue

By using Java 11, I am trying to find the average value inside the ArrayList. The algorithm i want to develop is ((value inside list/maximum value)*100)/length of list). I got number format runtime error while I run the program. java.lang.NumberFormatException is the error i got. enter image description here Answer I find two issues with the code above: The parsing

Sort List of Values in a Map in descending order

I have a Map with List of Doubles. unsorted map contents: {A=[0.02, 0.03], B=[0.0, 0.01], C=[0.01, 0.0], D=[0.05, 1.03], E=[1.01, 0.03]} I need to sort in descending order for List(0). I have tried the below logic but its sorting in ascending order. Actual output: {B=[0.0, 0.01], C=[0.01, 0.0], A=[0.02, 0.03], D=[0.05, 1.03], E=[1.01, 0.03]} Expected output: {E=[1.01, 0.03], D=[0.05, 1.03],

Advertisement