Java Code Examples for java.util.LinkedList#element()
The following examples show how to use
java.util.LinkedList#element() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkedListTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * element returns next element, or throws NSEE if empty */ public void testElement() { LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.element()); assertEquals(i, q.poll()); } try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} }
Example 2
Source File: CommandInjection.java From Android_Code_Arbiter with GNU Lesser General Public License v3.0 | 5 votes |
private String transferThroughList(String in, int index) { LinkedList<String> list = new LinkedList<String>(); list.add(System.getenv("")); // taints the list list.clear(); // makes the list safe again list.add(1, "xx"); list.addFirst(in); // can taint the list list.addLast("yy"); list.push(in); return list.element() + list.get(index) + list.getFirst() + list.getLast() + list.peek() + list.peekFirst() + list.peekLast() + list.poll() + list.pollFirst() + list.pollLast() + list.pop() + list.remove() + list.remove(index) + list.removeFirst() + list.removeLast() + list.set(index, "safe") + list.toString(); }
Example 3
Source File: LinkedListTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * element returns next element, or throws NSEE if empty */ public void testElement() { LinkedList q = populatedQueue(SIZE); for (int i = 0; i < SIZE; ++i) { assertEquals(i, q.element()); assertEquals(i, q.poll()); } try { q.element(); shouldThrow(); } catch (NoSuchElementException success) {} }