摘要: java字符串获取的相关方法: length, concat, indexOf 获取字符串长度 length int length = str.length(); 拼接字符串 concat String str1 = "Hello"; String str2 = "World"; String st 阅读全文
posted @ 2021-05-30 16:38 半袋咖啡 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 字符串之equals方法 String str = new String("Hello world!"); System.out.println(str.equals("Hello world!")); //true System.out.println(str.equals("abc")); // 阅读全文
posted @ 2021-05-30 16:07 半袋咖啡 阅读(47) 评论(0) 推荐(0) 编辑
摘要: java创建字符串 使用空参构造 String str1 = new String(); 根据字符数组创建字符串 char[] strArray = new char[]{ 'H', 'e'. 'l', 'l', 'o' }; String str2 = new String( strArray ) 阅读全文
posted @ 2021-05-30 15:51 半袋咖啡 阅读(401) 评论(0) 推荐(0) 编辑
摘要: ArrayList存储基本数据类型 错误写法! ArrayList<int> list = new ArrayList<>(); //报错:意外的类型 需要: 引用 找到: int ArrayList中只能存储引用数据类型 如果希望向ArrayList中存储基本数据类型,必须使用基本数据类型对应的" 阅读全文
posted @ 2021-05-30 00:24 半袋咖啡 阅读(460) 评论(0) 推荐(0) 编辑