zoukankan      html  css  js  c++  java
  • Java--Using the Deque Interface

    1.working with the ArrayDeque Class

     1 package self;
     2 
     3 import java.util.ArrayDeque;
     4 
     5 //import java.util.Hashtable;
     6 
     7 public class ArrayDequeDemo {
     8     public static void main(String args[]) {
     9         ArrayDeque<Double> obj = new ArrayDeque<Double>();
    10         Double dobj1 = new Double(7.5);
    11         Double dobj2 = new Double(8.5);
    12         Double dobj3 = new Double(9.5);
    13         Double dobj4 = new Double(10.5);
    14 
    15         System.out.println("Size of ArrayDeque is :" + obj.size());
    16 
    17         obj.add(dobj1);
    18         obj.add(dobj2);
    19 
    20         System.out.println("
    ArrayDeque after adding the objects:" + obj);
    21         System.out.println("Size of ArrayDeque after adding objects " + obj.size());
    22 
    23         obj.addFirst(dobj3);
    24         obj.addFirst(dobj4);
    25 
    26         System.out.println("ArrayDeque after adding the objects at first and last  " + obj);
    27         System.out.println("Size of ArrayDeque after adding objects at first and last " + obj.size());
    28 
    29         obj.removeFirst();
    30         System.out.println("
    ArrayDeque after removing the first object:" + obj);
    31         System.out.println("Size of ArrayDeque after removing the first objects " + obj.size());
    32 
    33     }
    34 }
    View Code

    测试结果:

  • 相关阅读:
    Codeforces Round #579 (Div. 3)
    2019牛客暑期多校训练营(第一场)ABBA
    Comet OJ
    Codeforces Round #562 (Div. 2)
    Codeforces Round #569 (Div. 2)
    寒假集训总结
    线段树做题总结
    Git学习
    unity开发vuforia血的教训
    (学习13)最短圆排列问题
  • 原文地址:https://www.cnblogs.com/Catherinezhilin/p/8990129.html
Copyright © 2011-2022 走看看