String类

1. 字符串比较规则

equals对比的是值和长度
==对比地址
就当等号不存在,无脑使用equals。

  System.out.println("a" == "a"); //trueSystem.out.println("a".equals("a")); //trueSystem.out.println("a".equals(new String("a"))); //trueSystem.out.println("a" == new String("a")); //falseSystem.out.println(new String("a") == new String("a")); //falseSystem.out.println(new String("a").equals(new String("a"))); //true

更要命的是,这些方法在特定情况下也是能够返回true的,具体原因可以通过阅读源码获知。

System.out.println("a".concat("") == "a"); //ture//replaceAll由于用到了StringBuffer的toString方法,会一直返回falseSystem.out.println("a".toLowerCase() == "a"); //tureSystem.out.println("1;2".split("3")[0] == "1;2"); //ture
2. 字符串的拼接

在JAVA中拼接两个字符串的最简便的方式就是使用操作符”+”了。如果你用”+”来连接固定长度的字符串,可能性能上会稍受影响,但是如果你是在循环中来”+”多个串的话,性能将指数倍的下降。假设有一个字符串,我们将对这个字符串做大量循环拼接操作,使用”+”的话将得到最低的性能。但是究竟这个性能有多差?
 1.String 是final对象,不会被修改,每次使用 + 进行拼接都会创建新的对象,而不是改变原来的对象,也属于线程安全的;
  2.StringBuffer可变字符串,主要用于字符串的拼接,属于线程安全的;(StringBuffer的append操作用了synchronized)
  3.StringBuilder可变字符串,主要用于字符串的拼接,属于线程不安全的;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
public class TestString {public static void main(String[] args) {//plus拼接字符串方式String s = "";long ts = System.currentTimeMillis();for (int i = 0; i < 10000; i++) {s = s + String.valueOf(i);}long te = System.currentTimeMillis();System.out.println("Plus cost {"+( te - ts) +"} ms");//concat拼接字符串方式String s2 = "";long ts2 = System.currentTimeMillis();for (int i = 0; i < 10000; i++) {s2 = s2.concat(String.valueOf(i));}long te2 = System.currentTimeMillis();System.out.println("concat cost {"+(te2 - ts2)+"} ms");//StringUtils.join拼接字符串方式List<String> list = new ArrayList<String>();long ts3 = System.currentTimeMillis();for (int i = 0; i < 10000; i++) {list.add(String.valueOf(i));}StringUtils.join(list, "");long te3 = System.currentTimeMillis();System.out.println("StringUtils.join cost {"+(te3 - ts3)+"} ms");//StringBuffer拼接字符串方式StringBuffer sb = new StringBuffer();long ts4 = System.currentTimeMillis();for (int i = 0; i < 100000; i++) {sb.append(String.valueOf(i));}sb.toString();long te4 = System.currentTimeMillis();System.out.println("StringBuffer cost {"+(te4 - ts4)+"} ms");//StringBuilder拼接字符串方式StringBuilder sb5 = new StringBuilder();long ts5 = System.currentTimeMillis();for (int i = 0; i < 100000; i++) {sb5.append(String.valueOf(i));}sb5.toString();long te5 = System.currentTimeMillis();System.out.println("StringBuilder cost {"+(te5 - ts5)+"} ms");}
}

StringBuilder类

StringBuilder类的作用
  1. 创建Stringbuilder对象
StringBuilder strB = new StringBuilder();
  1. append(String str)或者append(Char c):字符串连接
System.out.println("StringBuilder:"+strB.append("ch").append("111").append('c'));
//return "StringBuilder:ch111c"
  1. toString():返回一个与构建起或缓冲器内容相同的字符串
System.out.println("String:"+strB.toString());
//return "String:ch111c"
  1. setCharAt(int i, char c):将第 i 个代码单元设置为 c(可以理解为替换)char字符使用 ‘ ’
strB.setCharAt(2, 'd');
System.out.println("StringBuilder.setCharAt:" + strB);
//return "StringBuilder.setCharAt:chd11c"
  1. insert(int offset, String str)/insert(int offset, Char c):在指定位置之前插入字符(串)
ystem.out.println("StringBuilder.insertString:"+ strB.insert(2, "LS"));
//return "StringBuilder.insertString:chLSd11c"
System.out.println("StringBuilder.insertChar:"+ strB.insert(2, 'L'));
//return "StringBuilder.insertChar:chLLSd11c"
  1. delete(int startIndex,int endIndex):删除起始位置(含)到结尾位置(不含)之间的字符串
System.out.println("StringBuilder.delete:"+ strB.delete(2, 4));
//return "StringBuilder.delete:chSd11c"

7.StringBuilder类的reverse()实现字符串反转

public static String  reverse1(String str) {StringBuilder stringBuilder = new StringBuilder(str);StringBuilder str2 = stringBuilder.reverse();return str2.toString();}
StringBuilder类的内存分配

,而StringBuilder可以自由扩展大小,StringBuilder内存分配在堆区

StringBuffer类

StringBuffer线程安全

Math类

private void mathMethod(){// Math.sqrt()//计算平方根 Math.cbrt()//计算立方根 Math.hypot(x,y)//计算 (x的平方+y的平方)的平方根Log.d("TAG","Math.sqrt(16)----:"+Math.sqrt(16));//4.0Log.d("TAG","Math.cbrt(8)----:"+Math.cbrt(8));//2.0Log.d("TAG","Math.hypot(3,4)----:"+Math.hypot(3,4));//5.0// Math.pow(a,b)//计算a的b次方 Math.exp(x)//计算e^x的值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.pow(3,2)----:"+Math.pow(3,2));//9.0Log.d("TAG","Math.exp(3)----:"+Math.exp(3));//20.085536923187668//Math.max();//计算最大值 Math.min();//计算最小值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.max(2.3,4.5)----:"+Math.max(7,15));//15Log.d("TAG","Math.min(2.3,4.5)----:"+Math.min(2.3,4.5));//2.3//Math.abs求绝对值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.abs(-10.4)----:"+Math.abs(-10.4));//10.4Log.d("TAG","Math.abs(10.1)----:"+Math.abs(10.1));//10.1//Math.ceil天花板的意思,就是返回大的值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.ceil(-10.1)----:"+Math.ceil(-10.1));//-10.0Log.d("TAG","Math.ceil(10.7)----:"+Math.ceil(10.7));//11.0Log.d("TAG","Math.ceil(-0.7)----:"+Math.ceil(-0.7));//-0.0Log.d("TAG","Math.ceil(0.0)----:"+Math.ceil(0.0));//0.0Log.d("TAG","Math.ceil(-0.0)----:"+Math.ceil(-0.0));//-0.0Log.d("TAG","Math.ceil(-1.7)----:"+Math.ceil(-1.7));//-1.0//Math.floor地板的意思,就是返回小的值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.floor(-10.1)----:"+Math.floor(-10.1));//-11.0Log.d("TAG","Math.floor(10.7)----:"+Math.floor(10.7));//10.0Log.d("TAG","Math.floor(-0.7)----:"+Math.floor(-0.7));//-1.0Log.d("TAG","Math.floor(0.0)----:"+Math.floor(0.0));//0.0Log.d("TAG","Math.floor(-0.0)----:"+Math.floor(-0.0));//-0.0//Math.random 取得一个大于或者等于0.0小于不等于1.0的随机数[0,1Log.d("TAG","------------------------------------------");Log.d("TAG","Math.random()----:"+Math.random());//输出[0,1)间的随机数 0.8979626325354049Log.d("TAG","Math.random()*100----:"+Math.random()*100);//输出[0,100)间的随机数 32.783762836248144// Math.rint 四舍五入 返回double值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.rint(10.1)----:"+Math.rint(10.1));//10.0Log.d("TAG","Math.rint(10.7)----:"+Math.rint(10.7));//11.0Log.d("TAG","Math.rint(-10.5)----:"+Math.rint(-10.5));//-10.0Log.d("TAG","Math.rint(-10.51)----:"+Math.rint(-10.51));//-11.0Log.d("TAG","Math.rint(-10.2)----:"+Math.rint(-10.2));//-10.0Log.d("TAG","Math.rint(9)----:"+Math.rint(9));//9.0//Math.round 四舍五入 float时返回int值,double时返回long值Log.d("TAG","------------------------------------------");Log.d("TAG","Math.round(10.1)----:"+Math.round(10.1));//10Log.d("TAG","Math.round(10.7)----:"+Math.round(10.7));//11Log.d("TAG","Math.round(-10.5)----:"+Math.round(-10.5));//-10Log.d("TAG","Math.round(-10.51)----:"+Math.round(-10.51));//-11Log.d("TAG","Math.round(-10.2)----:"+Math.round(-10.2));//-10Log.d("TAG","Math.round(9)----:"+Math.round(9));//9//Math.nextUp(a) 返回比a大一点点的浮点数Log.d("TAG","------------------------------------------");Log.d("TAG","Math.nextUp(1.2)----:"+Math.nextUp(1.2));//1.2000000000000002//Math.nextDown(a) 返回比a小一点点的浮点数Log.d("TAG","------------------------------------------");Log.d("TAG","Math.nextDown(1.2)----:"+Math.nextDown(1.2));//1.1999999999999997//Math.nextAfter(a,b) 返回(a,b)或(b,a)间与a相邻的浮点数 b可以比a小Log.d("TAG","------------------------------------------");Log.d("TAG","Math.nextAfter(1.2, 2.7)----:"+Math.nextAfter(1.2, 2.7));//1.2000000000000002Log.d("TAG","Math.nextAfter(1.2, -1)----:"+Math.nextAfter(1.2, -1));//1.1999999999999997
}

System类

获取系统当前毫秒值

long start = System.currentTimeMillis();

结束正在运行的Java程序

System.exit(0);

用来运行JVM中的垃圾回收器,完成内存中垃圾的清除。

class Student{//清除垃圾时,会默认调用被清空对象的finalize方法。public void finalize() {System.out.println("垃圾已经被收取啦!");}
}public class SystemDemo {public static void main(String[] args) {new Student();new Student();new Student();new Student();new Student();System.gc();}
}

System类方法复制数组

public class SystemDemo {public static void main(String[] args) {int[] src = {1,22,333,4444,5555,666666,7777777};int[] dest = {10,20,30};System.arraycopy(src, 2, dest, 0, 2);for(int i=0;i<dest.length;i++) {System.out.println(dest[i]);}}
}

Object类

hashCode()方法

public class MyTest {public static void main(String[] args) {  Object obj = new Object();           //创建Object类对象   //int hashCode () 返回该对象的哈希码值。不同对象的哈希码值,是不一样的。//System.out.println(obj); 如果执行这条语句,打印的是局部变量obj里存放的地址值int i = obj.hashCode();System.out.println(i);Object obj2 = new Object();int i1 = obj2.hashCode();System.out.println(i1);}
}

getClass()方法

public class MyTest2 {public static void main(String[] args) {// Class<?> getClass () 返回该类的字节码文件对象//万物皆对象//Object.class 字节码文件加载进内存-----JVM就会为Object.class文件创建一个对象。Object obj = new Object();Class clazz = obj.getClass(); //Object.class---->字节码文件对象。Object obj2 = new Object();Class aClass = obj2.getClass();Object obj3 = new Object();Class aClass1 = obj3.getClass();System.out.println(obj==obj2); //false   //局部变量中存放的是地址值,对象不一样,所以地址值肯定不一样System.out.println(clazz==aClass); //trueSystem.out.println(aClass==aClass1);//true 因为类只有一个字节码文件,}
}

toString()方法

public class MyTest {public static void main(String[] args) {Object obj = new Object();String s = obj.toString(); //获取该对象的地址值的字符串表现形式java.lang.Object@1540e19dSystem.out.println(s);Object o = new Object();System.out.println(o.toString());System.out.println(o);}
}

equals()方法

/*** @Author: Administrator* @CreateTime: 2019-04-20 10:03*/
public class MyTest {public static void main(String[] args) {Object obj = new Object();Object obj2 = new Object();// boolean equals (Object obj) 判断两个对象的地址值是否相同System.out.println(obj == obj2);boolean b = obj.equals(obj2);System.out.println(b);System.out.println("---------------------");Student s1 = new Student("张三", 23);Student s2 = new Student("张三", 23);System.out.println(s1 == s2);//false//System.out.println(s1.equals(s2)); //true/*我觉得,s1.equals(s2) 比较两个对象的地址值,是否相同,对我来说意义不大,我认为的是,只要两个对象的成员变量的值一样,我就认为这两个对象一样。那么我就得重写父类的equals()方法,让他去比较两个对象的成员变量的值是否相同 */boolean b1 = s1.equals(new Teacher());//ClassCastException 类型转换异常System.out.println(b1);System.out.println("---------------");boolean b2 = s1.equals(s1);System.out.println(b2);}
}class Student {private String name;private int age;public Student(String name, int age) {this.name = name;this.age = age;}@Overridepublic boolean equals(Object obj) {if (this == obj) {return true;}if (!(obj instanceof Student)) {return false;}//向下转型Student stu = (Student) obj;//字符串类,也认为父类的equals方法不满意,字符串这个类想要比较,两个字符串的内容是否相同// 所以字符串也重写了父类的equals方法 去比较两个字符串的内容是否相同return this.name.equals(stu.name) && this.age == stu.age;}
}class Teacher {}

Arrays类

Arrays.asList()方法
注意:该方法返回的是 Arrays 内部静态类 ArrayList,而不是我们平常使用的 ArrayList,,该静态类 ArrayList 没有覆盖父类的 add(), remove() 等方法,所以如果直接调用,会报 UnsupportedOperationException 异常

List<Integer> list = Arrays.asList(1, 2, 3);
list.forEach(System.out::println); // 1 2 3
Integer[] data = {1, 2, 3};
List<Integer> list = Arrays.asList(data);
list.forEach(System.out::println); // 1 2 3

Arrays.fill(Object[] array, Object obj)方法
用指定元素填充整个数组 (会替换掉数组中原来的元素)

Integer[] data = {1, 2, 3, 4};
Arrays.fill(data, 9);
System.out.println(Arrays.toString(data)); // [9, 9, 9, 9]
Integer[] data = {1, 2, 3, 4};
//用指定元素填充数组,从起始位置到结束位置,取头不取尾 (会替换掉数组中原来的元素)
Arrays.fill(data, 0, 2, 9);
System.out.println(Arrays.toString(data)); // [9, 9, 3, 4]

Arrays.sort(Object[] array)
对数组元素进行排序 (串行排序)

String[] data = {"1", "4", "3", "2"};
System.out.println(Arrays.toString(data)); // [1, 4, 3, 2]
Arrays.sort(data);
System.out.println(Arrays.toString(data)); // [1, 2, 3, 4]

Arrays.equals(Object[] array1, Object[] array2)
判断两个数组是否相等
数组元素为基本数据类型时,依次比较值
数组元素为引用数据类型时,依次调用元素的 equals() 方法进行比较

Integer[] data1 = {1, 2, 3};
Integer[] data2 = {1, 2, 3};
System.out.println(Arrays.equals(data1, data2)); // true
//判断两个多维数组是否相等
Integer[][] data1 = {{1,2,3}, {1,2,3}};
Integer[][] data2 = {{1,2,3}, {1,2,3}};
System.out.println(Arrays.deepEquals(data1, data2)); // true

Arrays.hashCode(Object[] array)
返回数组的哈希值

Integer[] data = {1, 2, 3};
System.out.println(Arrays.hashCode(data)); // 30817
//返回多维数组的哈希值
Integer[][] data = {{1, 2, 3}, {1, 2, 3}};
System.out.println(Arrays.deepHashCode(data)); // 987105

Arrays.toString(Object[] array)
返回数组元素的字符串形式

Integer[] data = {1, 2, 3};
System.out.println(Arrays.toString(data)); // [1, 2, 3]
//返回多维数组元素的字符串形式
Integer[][] data = {{1, 2, 3}, {1, 2, 3}};
System.out.println(Arrays.deepToString(data)); // [[1, 2, 3], [1, 2, 3]]

Arrays.setAll(T[] array, IntFunction<? extends T> generator)
让数组中的所有元素

Integer[] data = {1, 2, 3, 4};
// i为索引值
Arrays.setAll(data, i -> data[i] * 2);
System.out.println(Arrays.toString(data)); // [2, 4, 6, 8]
Integer[] data = {1, 2, 3, 4};
// i为索引值
Arrays.parallelSetAll(data, i -> data[i] * 2);
System.out.println(Arrays.toString(data)); // [2, 4, 6, 8]
Integer[] data = {2, 3, 4, 5};
// 第一个元素2不变,将其与第二个元素3一起作为参数x, y传入,得到乘积6,作为数组新的第二个元素
// 再将6和第三个元素4一起作为参数x, y传入,得到乘积24,作为数组新的第三个元素,以此类推
Arrays.parallelPrefix(data, (x, y) -> x * y);
System.out.println(Arrays.toString(data)); // [2, 6, 24, 120]
Integer[] data = {2, 3, 4, 5};
// 第一个元素2不变,将其与第二个元素3一起作为参数x, y传入,得到乘积6,作为数组新的第二个元素
// 再将6和第三个元素4一起作为参数x, y传入,得到乘积24,作为数组新的第三个元素,以此类推
Arrays.parallelPrefix(data, 0, 3, (x, y) -> x * y);
System.out.println(Arrays.toString(data)); // [2, 6, 24, 5]

Arrays.stream(T[] array)

Integer[] data = {1, 2, 3, 4};
List<Integer> list = Arrays.stream(data).collect(toList());
System.out.println(list); // [1, 2, 3, 4]

日期Date类

Date类不常用,很多方法被废弃了,常用它的两个构造方法来new一个Date对象。

Date d1 = new Date();   //不传任何参数,代表当前时间点
System.out.println(d1);
//输出
Sat Jul 13 09:51:50 CST 2019
//在Java中以1970年1月1日 00:00:00为时间原点,由于时区问题,祖国时间是8:00:00
Date d2 = new Date(4000);   //传入一个long型数值,表示在时间原点之后
System.out.println(d2);//输出,时间过了4秒
Thu Jan 01 08:00:04 CST 1970

Collection

@Test
public void testCollection(){// 创建Collection接口的实现Collection collection = new ArrayList<>();// 添加元素collection.add("嘻嘻");String src = "????";collection.add(src);System.out.println(collection);// 创建Collection的实现Collection<String> coll = new HashSet<>();coll.add("?");coll.add("?");coll.add("?");System.out.println(coll);// 添加一个集合数据collection.addAll(coll);// 输出集合的长度System.out.println(collection);// 判断是否包含System.out.println(collection.contains("?"));// 移除元素collection.remove("?");// 添加对象System.out.println("-------");collection.add(null);Collection<String> collection1 = new ArrayList<>();collection1.add("嘻嘻");collection1.add("?");// 求两个集合的交集(只保留collection1存在的元素)collection.retainAll(collection1);System.out.println(collection);// 清空元素collection.clear();System.out.println(collection);}

Collections工具类

  1. 概念1.1. java.util.Collection 是一个集合接口(集合类的一个顶级接口)。它提供了对集合对象进行基本操作的通用接口方法。Collection接口在Java 类库中有很多具体的实现。Collection接口的意义是为各种具体的集合提供了最大化的统一操作方式,其直接继承接口有List与Set。1.2.java.util.Collections 是一个包装类(工具类/帮助类)。它包含有各种有关集合操作的静态多态方法。此类不能实例化,就像一个工具类,用于对集合中元素进行排序、搜索以及线程安全等各种操作,服务于Java的Collection框
    Collections工具类常用方法
List<String> syncList = Collections.synchronizedList(new ArrayList<String>());//相当于是把new ArrayList<String>()这个list包装了下,//编程可同步的新的list作者:Chaweys
链接:https://www.jianshu.com/p/b8fcf369969e
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

List

List集合的遍历有三种方式:

//使用普通的for循环for (int i = 0; i < list.size(); i++) {String s = list.get(i);System.out.println(s);}//使用迭代器
Iterator<String> iterator = list.iterator();while (iterator.hasNext()) {String next = iterator.next();System.out.println(next);}//用增强forfor (String s : list) {System.out.println(s);}

List以下的实现类

  1. ArrayList(查询快,增删慢。)
    非线程安全
    基于对象数组
    get(int index)不需要遍历数组,速度快;
    iterator()方法中调用了get(int index),所以速度也快
    set(int index, E e)不需要遍历数组,速度快
    add方法需要考虑扩容与数组复制问题,速度慢
    remove(Object o)需要遍历数组,并复制数组元素,速度慢
    remove(int index)不需要遍历数组,需要复制数组元素,但不常用
    contain(E)需要遍历数组
  2. LinkedList(查询慢,增删快。)
    非线程安全
    基于环形双向链表
    get(int index)需要遍历链表,速度慢;
    iterator()方法中调用了get(int index),所以速度也慢
    set(int index, E e)方法中调用了get(int index),所以速度也慢
    add方法不需要考虑扩容与数组复制问题,只需创建新对象,再将新对象的前后节点的指针指向重新分配一下就好,速度快
    remove(Object o)需要遍历链表,但不需要复制元素,只需将所要删除的对象的前后节点的指针指向重新分配一下以及将所要删除的对象的三个属性置空即可,速度快
    remove(int index)需要遍历链表,但不需要复制元素,只需将所要删除的对象的前后节点的指针指向重新分配一下以及将所要删除的对象的三个属性置空即可,但不常用
    contain(E)需要遍历链表
  3. Vector(线程安全的ArrayList)
    线程安全
    扩容机制与ArrayList不同

Set

Set以下的实现类

  1. HashSet() (查询快,增删慢。)
    快速的定位、读取,会根据hash值来存放,因此读取出来的顺序未必就是插入的顺序。由于HashSet储存数据都是无序的,所以不能用get(i);来获取具体对象,所以我们必须通过遍历来得到HashSet的各个数据,由于是没有索引的,所以不能使用普通类型的for来遍历它,HashSet只能通过增强型for和迭代器来遍历它

增加 add(null);
删除 remove(news);
对比查找 contains(news);
清空集合 clear();
获取长度 size();

public class NewsHashSet {public static void main(String[] args) {News news = new News(1, "北京终于放晴了!", "新闻社");News news2 = new News(2, "香港回归纪念日", "人民新闻");News news3 = new News(3, "假奶粉事件曝光", "人民新闻网");//创建HashSet集合,储存无序,唯一的数据// HashSet是是使用equals来进行对象对比,确定数据是唯一的// 如果两个数据的对象是一致的,那么HashSet将会把这两个合并,只储存一个空间HashSet<News> set = new HashSet<News>();set.add(news);set.add(news2);set.add(news3);//由于HashSet储存数据都是无序的,所以不能用get(i);来获取具体对象// 所以我们必须通过遍历来得到HashSet的各个数据,由于是没有索引的// 所以不能使用普通类型的for来遍历它  //HashSet只能通过增强型for和迭代器来遍历它// 增强型forfor(News n : set){System.out.println(n.getID()+"\t"+n.getLitter()+"\t"+n.getAuthor());}System.out.println("*****************************************");//迭代器Iterator<News> it = set.iterator();while (it.hasNext()) {News n = it.next();System.out.println(n.getID()+"\t"+n.getLitter()+"\t"+n.getAuthor());}//set的各种方法// set增加set.add(null);//删除set.remove(news);//对比查找set.contains(news);//清空集合set.clear();//获取长度set.size();}
}
  1. TreeSet() (存入set容器中的内容是按照一定的顺序排列的 )
// 假设set是TreeSet对象,并且set中元素是String类型
String[] arr = (String[])set.toArray(new String[0]);
//增强for循环
for (String str:arr)System.out.printf("for each : %s\n", str);
// 假设set是TreeSet对象
for(Iterator iter = set.descendingIterator(); iter.hasNext(); ) { iter.next();
}
public class TreeSetDemo {public static void main(String args[]) {// Create a tree setTreeSet ts = new TreeSet();// Add elements to the tree setts.add("C");ts.add("A");ts.add("B");ts.add("E");ts.add("F");ts.add("D");System.out.println(ts);}
}
//return [A, B, C, D, E, F]
  1. LinkedHashSet()(既可以实现快速的定位读取,又可以满足读取出来的顺序就是插入顺序)
public class Demo02_LinkedHashSet {public static void main(String[] args) {LinkedHashSet<String> lhs = new LinkedHashSet<>();lhs.add("a");lhs.add("a");lhs.add("a");lhs.add("a");lhs.add("b");lhs.add("c");lhs.add("d");System.out.println(lhs);}
}-

Map

Map以下的实现类

HashMap

TreeMap

LinkedHashMap

HashTable

Java必备常用操作API相关推荐

  1. Java中常用的API

    文章目录 前言 一.java.lang String StringBuilder Integer parseXXX Math Object System Throwable Thread Runnab ...

  2. 【java中常用的API】

    java中有很多常用的API,它们提供了便捷的使用方法和工具类,让我们来看一看java中常用的API吧. 1.math类: 它包含基本的数字运算方法,如对数.指数.平方根和三角函数等,一般数据类型为d ...

  3. 五、Java中常用的API(通过包进行分类)————异常、多线程和Lambda表达式

    之前已经介绍了java.lang包下的相关类,今天将要补充两个常用的API:java.lang.Throwable和java.lang.Thread 一.异常(java.lang.Throwable) ...

  4. java+@api_Java 常用的api

    ## 常用的api ## #### 1.概述 #### > API(Application ProgrammingInterface,应用程序编程接口)是一些预先定义的函数,目的是提供应用程序与 ...

  5. hashset java api_java常用对象API中集合框架之HashSet

    之前在<java常用对象API之集合框架>这篇文章中已经将所有集合框架做了一个总体的大纲陈列,并阐述了所有Collection接口下的子接口和类的作用解释,那么接下来的文章智言还是想把里面 ...

  6. Java数组常用操作

    目录  1.数组长度  2.数组填充  3.数组复制  4.数组比较  5.数组排序  6.在数组中搜索指定元素  7.把数组转换成字符串 数组的常用操作包括数组的充.复制.比较.排序等.Java提供 ...

  7. JAVA笔记-常用操作

    一.使用String.format()格式化字符串 1:介绍         String类的format()方法用来创建格式化的字符串或者连接多个字符串对象     2:使用         Str ...

  8. Java开发指导记录表_常操:Java开发常用操作记录

    开发常用操作 一.nginx 相关 Windows下Nginx命令 命令均在 nginx 安装目录下执行: 启动:start nginx 或者 ./nginx.exe 停止:./nginx.exe - ...

  9. Java字符串常用操作

    Java String 类 字符串广泛应用 在 Java 编程中,在 Java 中字符串属于对象,Java 提供了 String 类来创建和操作字符串. 创建字符串 创建字符串最简单的方式如下:Str ...

最新文章

  1. 【图文教程】Ubuntu software解决下载速度过慢
  2. 【已解决】IDEA:Cannot start compiler:the SDK is not specified for module...
  3. Java中的内存泄露的几种可能
  4. 为什么移动硬盘不建议插在台式机前置USB接口上?
  5. 什么样的 python 可以可谓专业 PyPI 项目?刚刚学到三个概念:pep8、Sphinx、pytest与GitHub Action的集成
  6. 一位,四位数码管引脚图
  7. 转子系统动力学模型matlab程序代码
  8. 微信 JS-SDK 说明文档
  9. 科研日常中,有用的拼图软件
  10. ubuntu20.04中安装划词翻译_支持语音录入翻译的小爱同学鼠标让智能设备控制一手掌握...
  11. Android原生模拟器运行ARM APP
  12. hdmi怎么支持2k分辨率_官方确认!PS5将不支持原生2K分辨率,双11次世代设备升级注意排雷...
  13. 怎么用计算机测出来体脂,如何简单测算出自己的体脂率?
  14. AMBA协议介绍(1)——APB协议
  15. 恒讯科技报告:2021-2026年泰国数据中心市场机会
  16. 【Axure交互教程】利用全局变量实现跨页面传值
  17. 如何删除有外键关系的两张表的数据
  18. Android 2.3 Gingerbreader 正式发布,向游戏开发者献媚
  19. ECCV2020:夜晚深度图估计
  20. 计算机网络答案清华大学出版社,计算机网络答案(吴功宜版+清华大学出版社)2.ppt...

热门文章

  1. ZOJ - 3591 NIM
  2. Zjoi2011 看电影
  3. Python爬虫从入门到放弃(十三)之 Scrapy框架的命令行详解
  4. id,clientid 和 uniqueid 的区别
  5. java 反射初探(1)
  6. cassandra入门
  7. ArcGIS 9.3/9.3.1 客户端 API 更新信息--2009年5月
  8. HTML5 文档头部
  9. angular-数据绑定的最佳实践
  10. faster rcnn的tensorflow代码的理解