Java character / string

character

Character class operation for a single character. Character class wraps a primitive type char value in the subject.

Escape Sequences

Escape Sequences description
\t tab key
\b Back key
\n Wrap
\r Enter
\f Page breaks
\' apostrophe
\" Double quotes
\\ Backslash

Character method

method description
isLetter() Whether it is a letter
isdigit () Whether it is a numeric character
isWhitespace() Whether it is a blank character
isUpperCase() Whether it is capital letters
isLowerCase() Whether lowercase letters
toUpperCase() Specify uppercase letters
toLowerCase() Specify lowercase letters
toString() Returns a string of characters, a string of only 1

String

In Java, strings belong to the object, Java provides the String class to create and manipulate strings.

String class offers 11 kinds of construction method.

String class is immutable, once a String object is created, and that its value can not be changed.

The variable string

When the string changes, and requires the use of StringBuffer StringBuilder class.

And String class is different, and the StringBuffer StringBuilder class objects can be modified many times, and does not generate new unused objects.

StringBuilder class is presented in Java 5, the biggest difference between it and the StringBuilder StringBuffer that the method is not thread-safe (can not synchronize access).

Since the StringBuffer StringBuilder compared to the speed advantage, so in most cases recommend using the StringBuilder class. However, in the case of application requires thread-safe, you must use the StringBuffer class.

 

Guess you like

Origin www.cnblogs.com/blunFan/p/11668404.html