toCharArray()方法

   该方法的作用是返回一个字符数组,该字符数组中存放了当前字符串中的所有字符

public class toChar1{
	public static void main(String[] args){
		String s1=new String("I am Chinese");
		char c[]=s1.toCharArray();
		System.out.println("the length of c:"+c.length);
		System.out.println(c);
		System.out.println(new String(c));
		
		String s2=new String(c,1,2);
		System.out.println(s2);
	}
}

  String类中的toCharArray()方法

相关文章:

  • 2022-12-23
  • 2021-11-22
  • 2021-06-11
  • 2021-11-22
  • 2022-01-01
  • 2021-09-03
  • 2021-07-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-11-22
  • 2021-06-10
  • 2021-08-02
相关资源
相似解决方案