美文网首页
常用方法

常用方法

作者: jiahzhon | 来源:发表于2021-05-17 11:27 被阅读0次

    String

    • length()
    • charAt(下标) - 返回char
    • toCharArray() - 返回char数组
    • getBytes() - 返回字节数组
    • indexOf("字符") - 返回int,不存在返回-1
      • lastIndexOf("字符")
    • toUpperCase(); toLowerCase();
    • split("字符或正则") - 返回String数组
    • trim() - 去掉字符串左右空格
    • substring(int beginIndex,int endIndex) - 截取,不包含endIndex
    • equalsIgnoreCase
    • contains(String) - 返回boolean
    • startsWith
    • endsWith
    • replace(char oldChar,char newChar)
      • replaceAll()
      • replaceFirst()

    Arrays

    • binarySearch(Object[] a, Object key) - 数组要先排好
    • boolean equals(基本[] a, 基本[] a2)
    • sort(Object[] a) - 升序,基本数据类型
    • Arrays.copyOfRange(T[ ] original,int from,int to) - 不包含to
    • asList();

    List

    • subList(int fromIndex, int toIndex) - 不包含toIndex
    • toArray()

    相关文章

      网友评论

          本文标题:常用方法

          本文链接:https://www.haomeiwen.com/subject/hwtjjltx.html