摘要:
public class StringBuilderDemo02 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入一个字符串:"); Stri 阅读全文
posted @ 2022-01-17 19:56
大灰狼21
阅读(116)
评论(0)
推荐(0)
摘要:
StringBuilder转换为String public String toString() StringBuilder sb = new StringBuilder();sb.append("hello");String s = sb.toString();System.out.println( 阅读全文
posted @ 2022-01-17 19:46
大灰狼21
阅读(273)
评论(0)
推荐(0)
摘要:
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
阅读(37)
评论(0)
推荐(0)
摘要:
引入原因: 每次使用字符串拼接,都会创建新的字符串对象,耗时浪费空间。 String和StringBuilder区别: String不可变 StringBuilder可变 StringBuilder构造方法: StringBuilder sb = new StringBuilder();System 阅读全文
posted @ 2022-01-17 19:18
大灰狼21
阅读(55)
评论(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
阅读(24)
评论(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
阅读(21)
评论(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
阅读(13)
评论(0)
推荐(0)
摘要:
==: 基本类型:数据值 引用类型:地址值 比较字符串中的内容: public boolean equals(Object anObject) 阅读全文
posted @ 2022-01-17 16:56
大灰狼21
阅读(35)
评论(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
阅读(34)
评论(0)
推荐(0)
摘要:
Java.lang包下,无需导包 代表字符串,所有“abc”双引号包着的都是String类的对象 字符串特点: 不可变 可共享 效果相当于char[]字符数组,但底层是字节数组byte[] 构造方法: 快捷键:Alt+click关闭其他的类 1. 2. 3. 4. 阅读全文
posted @ 2022-01-17 11:34
大灰狼21
阅读(25)
评论(0)
推荐(0)

浙公网安备 33010602011771号