1. List

  • 初始化

    1. List<T> list = new ArrayList<T>();
  • 方法

    • add
    • get(key)
    • remove(key) | remove(value)
    • for(T s : list):
    • contains(value)
    • set(key,value)
    • isEmpty()
    • toString()
    • toArray()
  • 逆置
    1. Collections.reverse(list)

2. 双端队列 Deque

1)Deque有三种用途

  • 普通队列(一端进另一端出):

Queue queue = new LinkedList()或Deque<> deque = new LinkedList<>()

  • 双端队列(两端都可进出)

Deque<> deque = new LinkedList<>()

  • 堆栈

Deque<> deque = new LinkedList<>()

2)双端队列方法
image.png
[

](https://blog.csdn.net/devnn/article/details/82716447)
3)队列方法
image.png

4)栈方法
image.png

3. 常见数据类型之间的转换

1)int / float / double / char—> String
StringVar = **String.valueOf**(intVar/floatVar/doubleVar/charVar);

2)String —> int/float/double
Integer/long/double**.parseInt()**

  1. Int I = Integer.parseInt (intstring);
  2. Float f = Integer.parseInt (floatstring);
  3. Long lo = long.parseInt (longstring);
  4. Double d = double.parseInt (doublestring);

3)String —> char
Char a = String.**charA**t(index)

4)String —> boolean
Boolean tag = **Boolean.valueOf**("true")

4. Character类的常用方法

1)判断功能(静态方法)

  1. public static boolean isDigit(char ch); //数字
  2. public static boolean isLetter(char ch); //字母
  3. public static boolean isLowerCase(char ch); //小写字母
  4. public static boolean isUpperCase(char ch); //大写字母

2)转换功能(静态方法)

  1. public static int toLowerCase(char ch) //转换为小写
  2. public static int toUpperCase(char ch) //转换为大写

5. StringBuffer类的常用方法

1)构造方法
StringBuffer sb=new StringBuffer();

2)转换为String类型
String s=sb.**toString**();

3)追加字符串
sb.**append**(字符串)

4)插入字符串
sb.**insert**(位置,字符串)

6. Double保存两位小数

  1. double a = 100.2365;
  2. double b = 200.1
  3. DecimalFormat df = new DecimalFormat("0.00");
  4. //DecimalFormat df = new DecimalFormat("#.##");
  5. System.out.println(df.format(a));
  6. System.out.println(df.format(b));