Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1.  
  2.     public static void main(String []args) {
  3.         SLL<Integer> lista = new SLL<>();
  4.         lista.insertLast(3);
  5.         lista.insertLast(4);
  6.         lista.insertLast(7);
  7.         lista.insertLast(6);
  8.         lista.insertLast(4);
  9.         lista.insertLast(7);
  10.         lista.insertLast(3);
  11.         lista.insertLast(2);
  12.         SLLNode<Integer> last = lista.getFirst();
  13.         SLLNode<Integer> first = lista.getFirst();
  14.         SLLNode<Integer> prevLast = null;
  15.         while (last.succ != null) {
  16.             prevLast = last;
  17.             last = last.succ;
  18.         }
  19.        
  20.         prevLast.succ = null;
  21.         //System.out.println(lista.toString());
  22.         last.succ = first.succ;
  23.         first.succ = last;
  24.         //System.out.println(lista.toString());
  25.         lista.first = last;
  26.         first.succ = null;
  27.         prevLast.succ = first;
  28.         System.out.println(lista.toString());
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement