zoukankan      html  css  js  c++  java
  • String类题目methods总结

    用到的Class和methods:

    1. 类String

    (1)charAt

    String s;

    s.charAt(i);

    (2)split

    分割一个String用split:

    public String[] split(String regex)
    RegexResult
    : { "boo", "and", "foo" }
    o { "b", "", ":and:f" }

     

    (3) trim删除空格

    public String trim()
    Returns a copy of the string, with leading and trailing whitespace omitted.
     
     
    (4)equals
    public boolean equals(Object anObject)
    Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
    example: http://www.cnblogs.com/hygeia/p/4830911.html
     

     

    2. 类Character: http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html

    用法类似Character.isLetterOrDigit(s.charAt(i))

    (1) isLetterOrDigit(char ch)

    Determines if the specified character is a letter or digit.
    Return static boolean
    example: http://www.cnblogs.com/hygeia/p/4830949.html
     
    (2) toLowerCase(char ch)
    Converts the character argument to lowercase using case mapping information from the UnicodeData file.
    Return static char
     
    (3)isWhitespace(char ch)
    Determines if the specified character is white space according to Java.

     
    (4)isDigit(char ch)
    Determines if the specified character is a digit.
     
     
    3. 类StringBuilder:http://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html
     
    (1) append(char c)
    Appends the string representation of the char argument to this sequence.
     
    (2)toString()
    Returns a string representing the data in this sequence.
    return String
     
    4. 转化
    (1) Integer to String
    • String.valueOf(number) (my preference)
    • "" + number (I don't know how the compiler handles it, perhaps it is as efficient as the above)
    • Integer.toString(number)
    (2) String to Integer
      Integer x = Integer.valueOf(str);
      // or
      int y = Integer.parseInt(str);

     

     
  • 相关阅读:
    【软件测试】软件缺陷粗浅认识及白盒测试举例
    【软件测试】等价类划分
    【软件测试】对本门课程粗浅理解
    阿里云服务器本地ping超时,远程可以正常ping通
    不忘初心
    开源框架、控件、组件、插件记录
    Flex中窗口可随意拖拽功能实现
    初探数据类型相关问题
    [TSCTF-J 2021] 解题报告
    指针
  • 原文地址:https://www.cnblogs.com/hygeia/p/4793476.html
Copyright © 2011-2022 走看看