Advertisement
mikhail_dvorkin

ArrayList example

Oct 26th, 2016
2,549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. // Создать массив ArrayList'ов
  2. ArrayList<Integer>[] neighbors = new ArrayList[n];
  3. for (int i = 0; i < n; i++) {
  4.     neighbors[i] = new ArrayList<Integer>();
  5. }
  6.  
  7. // Добавить в один из них значение
  8. neighbors[a].add(b);
  9.  
  10. // Пройти по всем элементам одного из них
  11. for (int u : neighbors[v]) {
  12.    
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement