Vector:和c++的vector使用方法类似。

Vector<Integer> vec=new Vector<> ();

ArrayList:Java.util.ArrayList类是一个动态数组类型,也就是说,ArrayList对象既有数组的特征,也有链表的特征。

import java.util.*;

public class Main {
public static void main(String[] args) {
ArrayList<Integer> arr=new ArrayList<>();
arr.add(1);//添加
arr.add(2,6);
arr.size();//获取长度
arr.set(1, 4);//修改
int st=arr.remove(0);//删除
//arr.clear();//清空
//arr.get(1);//获取
int v=arr.indexOf(3);//获取索引
System.out.println(v);
} }

LinkedList:LinkedList 实现 Deque 接口,即能将LinkedList当作双端队列使用。

import java.util.*;

public class Main {
public static void main(String[] args) {
LinkedList<Integer> lin=new LinkedList<>();
lin.addFirst(st);//在首部加
lin.addLast(st);//在尾
lin.removeFirst();//移除首元素
lin.removeLast();//尾
lin.push(st);//压入栈
lin.pop();//弹出栈
} }

HashSet:无重复元素。

HashSet<Integer> hashset=new HashSet<>();

HashMap:

HashMap<Integer, Integer> map=new HashMap<>();

STL声明总结:

import java.util.*;

public class Main {

    public static void main(String[] args) {

        List<String> mylist1 = new ArrayList<>();
List<String> mylist2 = new LinkedList<>();
List<String> mylist3 = new Vector<>(); Vector<String> vec = new Vector<>(); Queue<String> que = new LinkedList<>(); Stack<String> sta = new Stack<>(); Set<String> myset = new HashSet<>();
Set<String> myset2 = new TreeSet<>(); // Good Map<String, Integer> mymap = new HashMap<>(); // Good
Map<String, Integer> mymap2 = new TreeMap<>();
}
}

最新文章

  1. iftop与dstat-一次网站故障分析经历
  2. Leetcode Copy List with Random Pointer
  3. ACM 杭电HDU 2084 数塔 [解题报告]
  4. MVC5 + EF6 + Bootstrap3 (15) 应用ModelState和Data Annotation做服务器端数据验证
  5. 前端科普文—为什么&lt;!DOCTYPE&gt; 不可或缺
  6. 用eclipse开发和调试postgresql-8.4.1
  7. Undefined index:
  8. Linux 下WordPress FTP帐号解决办法
  9. C++学习50 对字符串流的读写
  10. POJ 3468 A Simple Problem with Integers(线段树)
  11. websphere中由于实际应用没有卸载干净,导致安装不了。以下是完全卸载应用程序的方法
  12. (转)linux性能优化总结
  13. ubuntu 安装qq
  14. VS2010在WIN7 64位系统下架设网站及路由器配置
  15. Oracle查询指定某一天数据,日期匹配
  16. centos6.5图形界面NetworkManager 配置ip文件位置
  17. 【百度地图API】自定义可编辑的交通路线
  18. flask_session_源码剖析
  19. OC可点击的两种轮播图效果
  20. vue项目向小程序迁移调研

热门文章

  1. redis可以做什么?
  2. tp增删改查
  3. 索引及explain
  4. python eval( ) 使用详解
  5. #python# 使用代理和不使用代理对比
  6. go 结构体取代类
  7. Leetcode Lect3 二分法总结
  8. C#设计模式:适配器模式(Adapter Pattern)
  9. linux性能分析工具Swap
  10. ssh-keygen - 认证密钥的产生, 管理和转换