Advertisement
Guest User

Untitled

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