Q:

Creating duplicate records from an arraylist

[Froster,Seat1,Seat34,Seat35]

Does anyone know how i can duplicate this list to something like this
[Forster,Seat1],[Froster,Seat34]

and so on?
*Update!so this is what i have tried so far *
ArrayList<String> try1 = new ArrayList<String>();
        ArrayList<String> try2 = new ArrayList<String>();
        try1.add("Froster");
        try1.add("Seat1");
        try1.add("Seat23");
        try1.add("Seat35");
        System.out.println(try1);

        for (int i = 1; i<=try1.size(); i++){
            try2.add(try1.get(i));

        }
        System.out.println(try2);

So as you can see the seats start from the 1st index position,so now i want to store into another list as follow
{[Forster,Seat1] [Forster,Seat34]}

A:

Do it as follows:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<String> list = List.of("Froster", "Seat1", "Seat34", "Seat35");
        List<ArrayList<String>> lists = new ArrayList<ArrayList<String>>();
        String first = list.get(0);
        for (int i = 1; i < list.size(); i++) {
            lists.add(new ArrayList<String>(Arrays.asList(first, list.get(i))));
        }
        System.out.println(lists);
    }
}

Output:
[[Froster, Seat1], [Froster, Seat34], [Froster, Seat35]]

