zoukankan      html  css  js  c++  java
  • Transformation functionality for the String class

    String类的转换功能:
    package com.itheima_05;
    /*
     * 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[] chs = s.toCharArray();
            for(int x=0; x<chs.length; x++) {
                System.out.println(chs[x]);
            }
            System.out.println("-----------");
            
            //String toLowerCase():把字符串转换为小写字符串
            System.out.println("HelloWorld".toLowerCase());
            //String toUpperCase():把字符串转换为大写字符串
            System.out.println("HelloWorld".toUpperCase());
        }
    }

     数组里面的长度是属性。String类里面的长度是方法。

  • 相关阅读:
    C# winform 选择文件保存路径
    笔记
    Redis 队列好处
    异步线程
    WebApi 运行原理
    MVC ---- 怎删改查
    如何快速掌握一门新技术/语言/框架...
    膝盖中了一箭之康复篇
    翻译-Salt与Ansible全方位比较
    膝盖中了一箭之手术篇
  • 原文地址:https://www.cnblogs.com/lzp123456-/p/9741957.html
Copyright © 2011-2022 走看看