This method removes and returns the last element from this list.
Syntax:Library: java.util.LinkedList
public E removeLast()
Example:import java.util.LinkedList;
public class MainClass {
public static void main(String args[]) {
LinkedList ll = new LinkedList();
ll.add("B");
ll.add("C");
ll.add("D");
ll.add("E");
ll.add("F");
ll.addLast("Z");
ll.addFirst("A");
ll.add(1, "A2");
System.out.println("Original contents of ll: " + ll);
ll.remove("F");
ll.remove(2);
System.out.println("Contents of ll after deletion: " + ll);
ll.removeFirst();
ll.removeLast();
System.out.println("ll after deleting first and last: " + ll);
String val = ll.get(2);
ll.set(2, val + " Changed");
System.out.println("ll after change: " + ll);
}
}
License.
All information of this service is derived from the free sources and is provided solely in the form of quotations.
This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 310 / 158776613. Delta: 0.00237 с