java代码---charAt()和toCharry()的用法

总结:charAt()是返回字符型,把字符串拆分成某个字符,返回指定位置的字符。可以把字符串看成char型数组

package com.sads;
///输出一个大写英文字母的
public class XIE {
	public static void main(String[] args) {
		String s="hello world i lkie fjds";
		char c=s.charAt(6);
		System.out.println(c);// 该字符串返回第几个索引的字符
		char[] x=s.toCharArray();//你妹自动纠错,是数组,不是char类型
		System.out.println(x);
		
	}
}
w
hello world i lkie fjds

  

原文地址:https://www.cnblogs.com/langlove/p/3493441.html