Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author bdb52
- */
- public class DequeDriver {
- public static void main(String [] args){
- System.out.println("If it doesn't work i'll cry.");
- System.out.println();
- ArrayDeque <Integer> s = new ArrayDeque<>();
- s.addFirst(-1);
- s.addFirst(2);
- s.addFirst(3);
- s.addLast(4);
- s.addFirst(5);
- // System.out.println("Checkin' da size: " + s.size());
- System.out.println("Checking the contents of this bad boi (should be 5, 3, 2, -1, 4: ");
- for (Object i : s.toArray())
- System.out.print(i + " ");
- System.out.println();
- System.out.println("Whats first?(should be a 5): " + s.getFirst());
- System.out.println("Whats last? (should be a 4): " + s.getLast());
- System.out.println("Modifying Deque using offer...");
- System.out.println("Adding 55 to the front of the Deque using offerFirst: " + s.offerFirst(55));
- System.out.println("Whats the new first? (using peek, should be a 55): " + s.peekFirst());
- System.out.println("Adding 77 to the tail of the Deque using offerLast: " + s.offerLast(77));
- System.out.println("Whats last? (using peek, should be a 77): " + s.peekLast());
- //System.out.println("Removing the head: " + s.pollFirst());
- System.out.println("Checking if this bad boi contains a 3 (should be true): " + s.contains(3));
- System.out.println("Checking if this bad boi contains a 1 (should be a hard false): " + s.contains(1));
- System.out.println("Testing pollFirst: " + s.removeFirst());
- System.out.println("Testing pollLast: " + s.removeLast());
- System.out.println("Checking the contents of this bad boi (should be 5, 3, 2, -1, 4: ");
- for (Object i : s.toArray())
- System.out.print(i + " ");
- System.out.println();
- System.out.println("Testing the isEmpty method(should be false): " + s.isEmpty());
- System.out.println("Clearing the Deque...");
- s.clear();
- System.out.println("Checking to see if it worked(size should be 0): " + s.size());
- System.out.println("Double Checking by isEmpty(should be true): " + s.isEmpty());
- // System.out.println("Checking the contents of this bad boi (should be -1, 3, 5, 10): ");
- // for (Object i : s.toArray())
- // System.out.print(i + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement