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

    测试结果:

  • 相关阅读:
    nginx-rtmp-module搭建流媒体服务器
    rabbitmq安装
    opencv+python (3)
    linux命令
    mysql语句概览
    BUUCTF V&N-misc内存取证
    2018 HEBTUCTF 部分misc
    2020 安恒2月月赛 misc
    2018.6.1 铁三数据赛 复现
    2020 i春秋新春战疫公益赛 misc
  • 原文地址:https://www.cnblogs.com/Catherinezhilin/p/8990129.html
Copyright © 2011-2022 走看看