摘要:
public class StringBuilderDemo01 { public static void main(String[] args) { int[] arr = {1, 2, 3, 4}; String s = arrayToString(arr); System.out.printl 阅读全文
posted @ 2022-01-17 19:46
大灰狼21
阅读(73)
评论(0)
推荐(0)
摘要:
StringBuilder sb = new StringBuilder();sb.append("hello").append("world").append("java").append(100);System.out.println("sb" + sb); sb.reverse();Syste 阅读全文
posted @ 2022-01-17 19:31
大灰狼21
阅读(36)
评论(0)
推荐(0)
摘要:
引入原因: 每次使用字符串拼接,都会创建新的字符串对象,耗时浪费空间。 String和StringBuilder区别: String不可变 StringBuilder可变 StringBuilder构造方法: StringBuilder sb = new StringBuilder();System 阅读全文
posted @ 2022-01-17 19:18
大灰狼21
阅读(54)
评论(0)
推荐(0)
摘要:
public class StringTest05 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入一个字符串:"); String line 阅读全文
posted @ 2022-01-17 18:39
大灰狼21
阅读(20)
评论(0)
推荐(0)
摘要:
public class StringTest04 { public static void main(String[] args) { int[] arr = {1, 2, 3}; String s = arrayToString(arr); System.out.println(s); } pu 阅读全文
posted @ 2022-01-17 18:27
大灰狼21
阅读(20)
评论(0)
推荐(0)
摘要:
Scanner sc = new Scanner(System.in);System.out.println("请输入一个字符串:");String line = sc.nextLine();int smallCount = 0;int bigCount = 0;int numberCount = 阅读全文
posted @ 2022-01-17 18:08
大灰狼21
阅读(30)
评论(0)
推荐(0)
摘要:
public char charAt(int index) 索引从0开始 public int length() 返回字符串的长度 数组的长度:数组名.length 字符串的长度:字符串对象.length() 遍历字符串通用格式: for(int i=0;i< s.length;i++){ s.ch 阅读全文
posted @ 2022-01-17 17:57
大灰狼21
阅读(217)
评论(0)
推荐(0)
摘要:
String username = "fuckyou";String password = "shityou";for (int i = 0; i < 3; i++) { Scanner sc = new Scanner(System.in); System.out.println("请输入用户名: 阅读全文
posted @ 2022-01-17 17:12
大灰狼21
阅读(12)
评论(0)
推荐(0)
摘要:
==: 基本类型:数据值 引用类型:地址值 比较字符串中的内容: public boolean equals(Object anObject) 阅读全文
posted @ 2022-01-17 16:56
大灰狼21
阅读(30)
评论(0)
推荐(0)
摘要:
char[] chs={'a','b','c'}; String s1=new String(chs); String s2=new String(chs); JVM会先创建一个字符数组,每次new就会有一个新的地址,新对象 String s3="abc"; String s4="abc"; JVM 阅读全文
posted @ 2022-01-17 11:45
大灰狼21
阅读(33)
评论(0)
推荐(0)