Advertisement
Guest User

Untitled

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