首页 > 代码库 > String

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

 

String