组合吃烤串的各种方法
String a = "Hello"; String b = new String(" World"); //在循环里面的话要小心用 String c = a+b; // Hello World a += b; // Hello World String x = "Hello " + "World";
比较字符串
boolean x = a.equals(b); // compares string boolean y = (a == b); // compares address
StringBuffer
//虽是sb但是确实很聪明 StringBuffer sb = new StringBuffer("Hello"); sb.append(" World"); // add to end of string 添加 sb.delete(0, 5); // remove 5 first characters 删除 sb.insert(0, "Hello"); // insert string at beginning 插入 String s = sb.toString();
Java 语法 索引 ----- 字符串(String),布布扣,bubuko.com
时间: 2024-10-13 07:54:12