ArrayList<Integer> a=new ArrayList();
ArrayList<Integer> b=new ArrayList();
Array List <ArrayList<Integer>> c =new ArrayList();
c.add(a);
c.add(b);
//multiplication table
//alphabets //Using Arrays List
Alphabets storing them into a 2D ArrayList
import java.util.ArrayList;
public class Alphabet2DArrayList {
public static void main(String[] args) {
ArrayList<ArrayList<Character>> alphabet2D = new ArrayList<>();
for (int i = 0; i < 2; i++) {
ArrayList<Character> row = new ArrayList<>();
for (int j = 0; j < 13; j++) {
char letter = (char) ('A' + (i * 13 + j));
row.add(letter);
}
alphabet2D.add(row);
}
for (ArrayList<Character> row : alphabet2D) {
System.out.println(row);
}
}
}
import java.util.ArrayList;
import java.util.Collections;
public class ArrayListUtils {
// 1. Method to reverse an ArrayList of doubles
public static ArrayList<Double> reverseArrayList(ArrayList<Double> list) {
ArrayList<Double> reversedList = new ArrayList<>(list);
Collections.reverse(reversedList);
return reversedList;
}