Sort an arraylist of an arraylist of doubles

I am looking to sort an arraylist of arraylist of doubles and I require help?

I was informed that I need to implement comparator or comparable and then use the collection.sort to sort the list of list in order...

ArrayList<ArrayList> list = new ArrayList<ArrayList>()

If you look at the list of list as the following example:

c1-5.0,4.5,10.3,3.5

c2-2.5,1.0,7.8,8.6

c3-6.0,5.6,9.6,9.5

It show go to this

c1-2.5,1.0,7.8,3.5

c2-5.0,4.5,7.8,8.6

c3-6.0,5.6,10.3,9.5

JAVA Checking 10th place in a 2d Arraylist

I want to check if the last numbers in an arraylist are a 10.My data is in a 2d arraylist with 110 elements every 10 numbers is one node, I want to verify that the last digit of each node is a 10.

example: 1,2,3,4,5,6,7,8,9,10 in this case its true 1,12,3,4,8,5,4,8,9,8 in this case its false

        public static void main(String[]args){
           ArrayList<ArrayList<Double> > array= new ArrayList<ArrayList<Double> >();
            for (int i = 0; i < array.size(); i++){
                if(logic here){
                    System.out.println(not 10.0);
                }else{
                    system.out.pritnln(10.0);
                }
            }
        }

how can I implement the correct logic for this case? Thank you!!!

Find the smallest, largest and medium number by comparing 3 array list

How do I compare 3 Arraylist with each other and find the small, medium and large elements. I was thinking something like this but its not working.

ArrayList<interger> a = new ArrayList<ArrayList<interger> >(); 
a.add(1);
a.add(2);
a.add(7);
ArrayList<interger> b =new ArrayList<ArrayList<interger> >();
b.add(8);
b.add(9);
b.add(1);
ArrayList<interger> c = new ArrayList<ArrayList<interger> >();
c.add(5);
c.add(9)
c.add(8)

 for (int i = 0; i < ; i++) 
        {
            for (int j = 0; j < ; j++) 
            {
                for (int k = 0; k < ; k++) 
                {

        if () {}

        if () {}    

        if () {}
         }
      }}

output:
small =1,2,1
medium = 5,9,7
large = 8,9,8

Calculating distance with arraylist

I would like to calculate the distance in 4d I have 2 arraylist that have all of my elements in it. How do make the formula i have this but its not calculating correctly the distance. List has diferent coordinates every time and t always has the same coordinates.

        double w = 0.0;

        for (int i = 0; i < List.size(); i++)
        {
            for (int j = 0; j < List.get(i).size(); j++)
          {
           w =   Math.sqrt(Math.pow(List.get(i).get(j) - t.get(j), 2)+Math.pow(List.get(i).get(j) - t.get(j), 2)+Math.pow(List.get(i).get(j) - t.get(j), 2)+Math.pow(List.get(i).get(j) - t.get(j), 2));
          }
        System.out.println(w);

Divide arraylist of 750 into 150 sub arraylist

I have an ArrayList of 750 elements I would like to divide that ArrayList into 150 subarraylists so 5 elements to each subarraylist.

I have this code but it not working

while (scanner.hasNextLine()) {
            String t = scanner.nextLine();
            String[] ar = t.split(",");

            for (int i = 0; i < ar.length; i++) 
            {
                add.add(Double.parseDouble(ar[i]));
            }

Select every 5 numbers random

I have an array list that looks like this.

8.1,6.5,4.4,3.2,1,8.9,5,1.4,0.1,1,8.7,6.2,4.3,3.2,3

I would like that my program selects every 5 numbers randomly.

for example to select

8.1,6.5,4.4,3.2,1,8.7,6.2,4.3,3.2,3

as you can see it selected 5 numbers from the begging and 5 more from the end

and saves them

Random random_method = new Random();

// loop for generation random number
for (int i = 0; i < array.size(); i++)

// generating random index with the help of
// nextInt() method
int index = random_method.nextInt(array.size());

System.out.println("Random Element is :" + array.get(index));