...
- String pooling - http://java-performance.info/string-intern-in-java-6-7-8/
Методы
Блок кода | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
String description = "The class String includes methods for examining\n" +
" * individual characters of the sequence, for comparing strings, for\n" +
" * searching strings, for extracting substrings, and for creating a\n" +
" * copy of a string with all characters translated to uppercase or to\n" +
" * lowercase";
System.out.println("Length: "+description.length()+", is empty: "+description.isEmpty());
String[] words = description.split(" ");
for(String word : words) {
System.out.println(word);
}
String shortDescription = description.substring(10);
System.out.println(shortDescription);
shortDescription = description.substring(description.indexOf("String"));
System.out.println(shortDescription);
String usdNumber = "$101.78";
System.out.println(usdNumber.matches("\\$\\d*\\.\\d*"));
String stringWithPrice = "Cost is 101.56 USD in Target";
System.out.println(stringWithPrice.replaceAll("(\\d*\\.\\d*)( USD)", "\\$$1"));
String[] numbers = new String[] {"one", "two", "three"};
System.out.println(String.join(",", numbers)); |
StringBuilder и StringBuffer
...