zoukankan      html  css  js  c++  java
  • String常用方法

    1.charAt(int index)  返回String 对应位置上的字符

    2.length() 字符串的长度

    3.indexOf() 求某个字符在字符串中的位置

    4.equals()比较两个字符串是否相同

    5.trim()将字符串开头的空白(空格)和尾部的空白去掉

    6.split():根据给定正则表达式的匹配拆分此字符串。形如 String s = "The time is going quickly!"; str1=s.split(" ")

    7.replace():将字符串中的某些字符用别的字符替换掉。形如replace(“aaa”,”ddd”);字符串中的aaa将会被ddd替换掉

    8.toLowerCase():将字符串中所有的大写改变成小写

    9.toUpperCase():将字符串中所有的小写改变为大写

    10.String substring(int beginIndex, int endIndex) :取从beginIndex位置开始到endIndex位置的子字符串。

    不积跬步无以至千里。不善思考无以踏捷径。
  • 相关阅读:
    config https in nginx(free)
    js hex string to unicode string
    alter character set
    es6
    音乐播放器
    JS模块化-requireJS
    PHP中的封装和继承
    JavaScriptOOP
    mui框架移动开发初体验
    走进AngularJS
  • 原文地址:https://www.cnblogs.com/tiankc/p/9641833.html
Copyright © 2011-2022 走看看