Advertisement
cd62131

List<List<Integer>> example

May 8th, 2018
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.54 KB | None | 0 0
  1. import java.util.LinkedList;
  2. import java.util.List;
  3.  
  4. public class LList {
  5.   public static void main(String[] args) {
  6.     List<List<Integer>> list = new LinkedList<>();
  7.     for (int x = 0; x < 9; ++x) {
  8.       list.add(new LinkedList<>());
  9.       for (int y = 0; y < 9; ++y) {
  10.         list.get(x).add((x + 1) * (y + 1));
  11.       }
  12.     }
  13.     list.stream().forEach(System.out::println);
  14.     for (int i = 0; i < 9; ++i) {
  15.       list.get(i).set(i, 0);
  16.     }
  17.     System.out.println();
  18.     list.stream().forEach(System.out::println);
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement