String类的转换功能

/*
 *   String类的转换功能
 *   char[] toCharArray():把字符串转换为字符数组
 *   String  toLowerCase():把字符串转换为小写字符串
 *   String toUpperCase():把字符串转换为大写字符串
 *   
 *   
 *   字符串的遍历:
 *      A:length()加上charAt()
 *      B:把字符串转换为字符数组,然后遍历数组
 */
public class StringDemo {
    public static void main(String[] args) {
        //创建字符串对象
        String s="abcde";
        //char[] toCharArray()把字符串转换为字符数组
        char[] ch=s.toCharArray();
        for(int x=0;x<ch.length;x++)
        {
            System.out.println(ch[x]);
        }
        System.out.println("------");
        System.out.println("HelloMOTO".toLowerCase());
        System.out.println("babycome".toUpperCase());
    }

}
原文地址:https://www.cnblogs.com/long-holiday/p/10136249.html