admin管理员组

文章数量:1794759

JAVA中的charAt函数和toCharArray函数

JAVA中的charAt函数和toCharArray函数

1.charAt函数 这个函数就是将字符串中的某个位置的字符返回出来。 例子:String s = “student”; char c = s.charAt(1); 结果是:字符t

2.toCharArray函数 这个函数就是将字符串对象的字符转化为字符数组; public class Test2 { public static void main(String[] args){ String s = “hello”; char []c; c = s.toCharArray(); System.out.println(c); } }

本文标签: 函数javacharAttoCharArray