I have the following ArrayList List<DataSt> list1 where list1 has the following values (floats):
<25.89, 21.23>
< 5.89, 1.23>
< 3.69, 20.23>
< 2.89, 121.23>
<125.89, 231.23>
.
.
.
< 28.89, 41.23>
And DataSt has the following structure:
public class DataSt {
private float a;
private float b;
public DataSt(float a , float b){
this.a=a;
this.b=b;
}
}
Now I need to find the minimum from the first column i.e., from <25.89, 5.89, 3.69, 2.89, 125.89 ... 28.89> it must return 2.89
Then find max from <25.89, 5.89, 3.69, 2.89, 125.89 ... 28.89> it must return 125.89
Now repeat the same for second column and store them with 4 different variables say min_col1,max_col1,min_col2 and max_col2 respectively.
min_col1 = 2.89
max_col1 = 125.89
min_col2 = 1.23
max_col2 = 231.23
I have been looking through various solutions that suggest using two for loops with is really time consuming also some threads suggested using stream() which was finding for the whole list (i.e., not for every column).
Is there an efficient way to do this? I am also looking at Apache Commons as well.