java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容结束------------

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容结束------------

------------恢复内容结束------------

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容结束------------

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容开始------------

java中的所有的字符串文字(例如"abc","123")都可以看做是实现了此类的实例对象

eg:

    String str = new String();
str = "123";
str = "abc";

String类的特点:

     1.字符串字面值常量,不变的
2.实现共享
3.内部封装了很多对于字符和字符串操作的API方法
4.Java 语言提供对字符串串联符号("+")以及将其他对象转换为字符串的特殊支持。
5.凡是能够用"+"连接字符串的结果值类型都会转变成字符串类型
通过StringBuilder中的append方法实现的(把两种类型相加)
字符串转换通过toString方法实现的(变为字符串)
true +"" --> "true"
123 + "" --> "123"
3.14 + ""--> "3.14"

String类的常用用法以及使用格式:

序号旁边的是使用格式

    //1.charAt(int index )返回指定索引处的字符值

      String str = "abcds";
      char sss = str.charAt(3);
      System.out.println(sss);

char ssss = str.charAt(6);这个索引越界
System.out.println(ssss);
     //相当于字符串的索引,设置好字符串,用charAt对第四个字符定位输出,
     //其中定位数字3不能越界这里的字符串长度为6,因为是从0开始所以最大定位数字为5,

//2.codePoinAt(int index) //根据字符串的索引进行定位并转换成阿斯克码表上其对应的序号
     String str = "aBbcds"
int codePointAt = str.codePointAt(1);
System.out.println(codePointAt);// B -->66 b-->98(根据阿斯克码表)


  //3.compareTo(String str)
int compareTo = str2.compareTo(str);
//this.charAt(k)-anotherString.charAt(k)
//this.length()-anotherString.length()
System.out.println(compareTo);
//4.compareToIgnoreCase(String str) 忽视大小写比较字符串
int compareToIgnoreCase = str2.compareToIgnoreCase(str);
//5.concat(String str)
String concat = str.concat(str2);
System.out.println(concat);// Abc123afg123
//6.Contains(CharSequence s) [重要]
boolean contains = str2.contains("f23");// f23是一个整体不可分割
System.out.println(contains);//true false
//7.endsWith(String suffix ) suffix 后缀 prefix 前线
boolean endsWith = str2.endsWith("23");
System.out.println(endsWith);
//8 starsWith(String prefix) [重要] 是否以某个字符串为结尾
boolean StartsWith = str2.startsWith("afg");
System.out.println(StartsWith);
//9. 相等判断equals(Object o) 重要 相等判断
boolean equals = str.equals(str2);
System.out.println(equals);
//10.getBytes() byte[] "afg123"
byte[] bytes = str2.getBytes();
for (int i = 0; i < bytes.length; i++) {
System.out.print(bytes[i] + " ");
}
// UTF-8 GBK ISO-8859-1 Unicode //src 来源 dst 目的地
char[] dst = new char[10];// 10个元素 (没有东西)
//11.getChars(int srcBegin,int srcEnd,char[] dst,int dstBegin)
//"afg123"
str2.getChars(2, 5, dst,4);//第五个位置
for (int i = 0; i < dst.length; i++) {
System.out.println(dst[i] + " ");
}
//str2 = "afg123"
//12. int indexOf(String str) 获取字符串第一次出现该字符串对应的索引位置 【重要】
int indexOf = str2.indexOf("12");//
System.out.println(indexOf);// 3
//13. int length()获取字符串的长度值 【重要】
int length = str2.length();
System.out.println(length);
//14.replace(CharSequence target, CharSequence replacement)
String replace = str2.replace("a", "e");// 把旧的字符串替换成新的字符串
System.out.println(replace);//ebc123ebc456
//15. split(String regex)根据指定的字符分割成字符串数组【重要】
//regex - 定界正则表达式
String str4 = "张三-李四-王五-赵六-abc";
String[] split = str4.split("-");
//相当于split = {"张三","李四","王五","赵六","abc"}
for (int i = 0; i < split.length; i++) {
System.out.print(split[i] + " ");
}
System.out.println();
String str5 = "abc.bcd.fff.123";
String[] split2 = str5.split("\\.");// 用.分割的话需要用需要用双反斜杠
// \---反斜杠 /---正斜杠 在字符串中"\"代表转义
for (int i = 0; i < split2.length; i++) {
System.out.print(split2[i] + " ");// abc bcd fff 123
} System.out.println();
String str6 = "123456789abc";
String[] split3 = str6.split("");//空字符串做分隔符
for (int i = 0; i < split3.length; i++) {
System.out.print(split3[i] + " ");//1,2,3,4,5,6,7,8,9,a,b,c
} //16.substring(int beginIndex,int endIndex) [a,b) 截取字符串 生成一个新的字符串
// 获取str6字符串中6789值
String substring = str6.substring(5, 9);
System.out.println(substring); //17. toLowerCase()小写 toUpperCase()大写
//18.String trim(() 去掉该字符串前后两端的空格
String str7 = " abc 123 ";
System.out.println("--"+str7+"--");
String trim = str7.trim();
System.out.println("--"+ trim + "--");
//19. static valueOf(Object o) 把非字符串类型转换成字符串类型,内容值不变
String valueOf = String.valueOf(abc);
System.out.println(valueOf);//123

------------恢复内容结束------------

------------恢复内容结束------------

------------恢复内容结束------------

16 String类的更多相关文章

  1. C++语言基础(16)-string类

    使用 string 类需要包含头文件<string>,下面的例子介绍了几种定义 string 变量(对象)的方法: #include <iostream> #include & ...

  2. 源码学习-String类

    最近在扫描CodeDex时报了一个不能使用String.intern()的字符串来做锁对象的告警,对这个问题有疑问查了些资料,顺便学习一下String类的源码. 1.类定义 String 被final ...

  3. 《C++ Primer Plus》16.1 string类 学习笔记

    16.1.1 构造字符串程序清单16.1使用了string的7个构造函数.程序清单16.1 str1.cpp---------------------------------------------- ...

  4. C++ primer plus读书笔记——第16章 string类和标准模板库

    第16章 string类和标准模板库 1. string容易被忽略的构造函数: string(size_type n, char c)长度为n,每个字母都为c string(const string ...

  5. 《C++ Primer Plus》第16章 string类和标准模板库 学习笔记

    C++提供了一组功能强大的库,这些库提供了很多常见编程问题的解决方案以及简化其他问题的工具string类为将字符串作为对象来处理提供了一种方便的方法.string类提供了自动内存管理动能以及众多处理字 ...

  6. String类和StringBuffer类的区别

    首先,String和StringBuffer主要有2个区别: (1)String类对象为不可变对象,一旦你修改了String对象的值,隐性重新创建了一个新的对象,释放原String对象,StringB ...

  7. String 类相关知识

    1.常用方法 1)判断字符串是否为空 public boolean isEmpty()2)获取字符串长度 public int length()3)截取子子串 public String substr ...

  8. Java String类的常用方法

    String(byte[ ] bytes):通过byte数组构造字符串对象. String(char[ ] value):通过char数组构造字符串对象. String(Sting original) ...

  9. [C++][语言语法]标准C++中的string类的用法总结

    转自:http://www.cnblogs.com/xFreedom/archive/2011/05/16/2048037.html 要想使用标准C++中string类,必须要包含 #include ...

随机推荐

  1. MySql WorkBench 导入sql文件 中文出现乱码

    在workbench中导入sql文件. 查看系统的编码. 导入sql文件时出现了如下警告.但是文件是UTF-8.由于包含中文,使用latin1编码方式会出现乱码. 选择UTF-8,出现错误. 不知道什 ...

  2. Java程序运行内存机制

    Java程序运行内存机制 栈内存包留调用方法.变量的区域,堆内存是new对象的区域,方法区为保存class文件的区域. 程序刚开始时,先加载类文件相应的数据到方法区,然后就从main()方法开始执行. ...

  3. 虚拟机CentOS开机黑屏解决方案

    默认配置 错误: 1.直接就是黑屏,连杠杠都没有 2.centos系统关不掉 3.关闭vmware提示:虚拟机XXX繁忙 解决方案一: 1.以管理员身份运行cmd控制台程序 2.在cmd窗口中输入ne ...

  4. git将本地仓库中的文件上传到远程仓库

    现在我们开始创建本地git仓库(版本库又叫仓库) (本地仓库:$ git init之后的目录): 1.任意地方新建文件夹aaa,右击git bash here, 2.弹出一个对话框, 3. 首先配置你 ...

  5. python 魔法方法诠释

    什么是Python魔法方法 什么是魔法方法呢?它们在面向对象的Python的处处皆是.它们是一些可以让你对类添加"魔法"的特殊方法. 它们经常是两个下划线包围来命名的(比如 ini ...

  6. Python-列表推导式、生成器、字典推导式

    列表推导式 [] + for + if 算子.循环.条件, 对相同的数据进行处理, 算子也可以是函数 number = [i for i in range(1, 101) if i % 2 == 0] ...

  7. MacOS如何正确配置Idea自带Maven插件的环境变量?(亲测)

    背景 安装了IDEA开发工具,想执行Maven的命令.但是又没有通过自己下载Maven的安装包进行安装,只是想直接使用IDEA自带的Maven插件来执行Maven的各种命令.由于刚开始使用macos对 ...

  8. 094 01 Android 零基础入门 02 Java面向对象 02 Java封装 01 封装的实现 03 # 088 01 Android 零基础入门 02 Java面向对象 02 Java封装 02 static关键字 04 static关键字(续)

    094 01 Android 零基础入门 02 Java面向对象 02 Java封装 01 封装的实现 03 # 088 01 Android 零基础入门 02 Java面向对象 02 Java封装 ...

  9. 087 01 Android 零基础入门 02 Java面向对象 02 Java封装 01 封装的实现 01 封装的概念和特点

    087 01 Android 零基础入门 02 Java面向对象 02 Java封装 01 封装的实现 01 封装的概念和特点 本文知识点:封装的概念和特点 说明:因为时间紧张,本人写博客过程中只是对 ...

  10. Python 为什么不支持 switch 语句?

    本文出自"Python为什么"系列,请查看全部文章 在这篇文章里,我们会聊一聊为什么 Python 决定不支持 switch 语句. 为什么想要聊这个话题呢? 主要是因为 swit ...