String

1, .intern() method, return String

call .intern() method, will try to add current string into the pool, if the pool already has the string, the method will return the ref to the existing string; otherwise, it will add the string into the pool.

2, Reverse a String

new StringBuilder(str).reverse().toString();

3, change case

.toLowerCase(), .toUpperCase()

4, Compare

.equalsIgnoreCase(String anotherStr) return boolean.

.compareTo(String anotherStr) return int 0 or negative or positive.

.compareToIgnoreCase(String anotherStr).

5, to chars

.toCharArray() return char[]

.charAt(int index) return char

6, split(String regex) return String[]

Note that " 2" will generate {"", "2"}

原文地址:https://www.cnblogs.com/chayu3/p/4014590.html