用到的Class和methods:
1. 类String
(1)charAt
String s;
s.charAt(i);
(2)split
分割一个String用split:
public String[] split(String regex)
Regex | Result |
---|---|
: | { "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.
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.return StringBuilder
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);