javase--Common Classes

Source: Internet
Author: User

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

· String Immutable string

Character set: is the corresponding table of text and encoding, and also a formatted table of characters. Text is stored by converting the character set table to bytes, so different character sets, the converted bytes are not the same.
GetBytes character to byte array
GetBytes () converts to a byte array by the current character set
GetBytes (Charset) sets the character set converted to a byte array
GetBytes (String) sets the character set converted to a byte array
In the future programming in Chinese garbled or other garbled characters must be a character set problem, to know what character set they use, and then to convert

Split string by keyword Plit (string)

Replace String method
Replace (string,string) is replaced by a string
Replace (Char,char) Single-character replacement
ReplaceAll (string,string) is replaced by regular expression

String constructor
String (String)
String (char[])
String (Char[],int,int)
String (byte[])
String (Byte[],charset)
String (byte[],string)

StringBuffer variable string
StringBuffer each time a new string is added, there will be a request for an array, and not every time to apply for the big, because a large number of applications, the space used to expand, and then import the previous string, append the new string, and so on, so that the variable string.
Method:
Append string Append ()
Insert insertion (int, content) at specified position

StringBuilder:
The difference between the StringBuffer and the whole method is that the Security keyword is not synchronized. StringBuilder no sync security
If a thread is manipulating a string, use StringBuilder
If the string is a multithreaded operation, use StringBuffer

Package data type:
Int-->integer
Byte-->byte
Short-->short
Long-->long
Float-->float
Double-->double
Char-->character
Boolean-->boolean
Encapsulated data type before jdk1.5 we call it the tool class
After jdk1.5 (including 1.5) the encapsulated data type can also be used as a single data type
Automatic Boxing
Encapsulates the data type to accept the basic type of data, it will automatically give you boxing

Automatic unpacking
The base data type accepts the encapsulated data type object, which automatically calls the method that encapsulates the data type for the unboxing operation

It should be noted that the encapsulation data type comparison, you should use equals to compare, after all, they are objects
Method:
Turn the string

Conversion of numerical values on the binary

Integer converted to string

MD5 encryption
Encryption can not decrypt an encryption method, encryption is a string of ciphertext, as long as the same content encrypted out of the cipher is the same
Compare, can only compare ciphertext, as long as the same ciphertext is the same content we note that encryption requires nested encryption, is the most insurance

Some of the common operating classes:
Math Maths Class
Stochastic random number class

System
Runtime

Robot

javase--Common Classes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.