1、
char[] value ={'a','b','c','d'};
String str = new String(value);//输出 abcd
2、
char[] value ={'a','b','c','d'};
String str = new String(value, 1, 2);输出 bc

3、

String的常用方法和作用//获取字符串的长度

 

 

 4、

String的常用方法和作用

 

 

  5、

String的常用方法和作用

 

 

  6、

String的常用方法和作用

 

 

  7、

String的常用方法和作用

 

   获取字符在str中第一次出现的地方

String的常用方法和作用

 

  8、

String s = "helloworld";
// 从beginIndex开始截取字符串到字符串结尾
System.out.println(s.substring(0));//helloworld
System.out.println(s.substring(5));//world

   和

String s = "helloworld";
 // 从beginIndex到endIndex截取字符串。含beginIndex,不含endIndex。
System.out.println(s.substring(0, s.length()));//helloworld
System.out.println(s.substring(3,8));//lowor

相关文章: