首页 > 其他 > 详细

String类中的toCharArray()方法

时间:2016-08-19 22:03:51      阅读:181      评论:0      收藏:0      [点我收藏+]

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()方法

原文:http://www.cnblogs.com/GumpYan/p/5789008.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!