java common API

String handling:
String str = "..............";
*str.equals(); // Compare the value of two strings for equality
== In addition to the underlying data type, Compare whether the addresses pointed to by two variables are the same
equals Compare whether the values ​​of two objects are equal
*str.length();// Get the length of the entire string
str.trim();// Remove the spaces on both sides of the string
str.charAt (int i);// Get the character on an index value
str.contains(CharSequence s);// Whether it contains a string
str.startsWith(String s); // Determine whether to start with a string
str . .endsWith(String s); // Determine if it ends with a string
replace(char o, char n); // Replace all o's in the string with n
replace(CharSequence o, CharSequence n);// Same as above
*split(String s); // split the string
toUpperCase(); // convert the string to uppercase
toLowerCase(); // convert to lowercase
valueOf(any args); // get a string instance with any arguments
* str.indexOf(String s);//Get the index position of the first occurrence of this string
str.lastIndexOf(String s);//Get the index position of the last occurrence of this string
str.substring(int i);//Get the index value of the string following the integer parameter
str.substring(int a, int b );//Take the string between a and b (excluding b)

StringBuffer (with buffer) is mainly used to construct strings
*StringBuffer append(char c) // Append
StringBuffer insert(int offset, String str) // Insert a string at an index position
StringBuffer deleteCharAt(int index)
StringBuffer delete (int start, int end)
StringBuffer replace(int start, int end, String s)
StringBuffer setCharAt(int index, char ch)
String toString()
StringBuffer reverse() // reverse the string

System class
// Exit the currently running java virtual machine, 0 means exit normally
static void exit(int status)
static long gc() // Manually start the garbage collection mechanism It
is not recommended to manually call System.gc();
out of variable scope The object will be reclaimed by the garbage collection mechanism in time. The
finalize method is automatically called
long static currentTimeMillis() // Returns the current system time (in the form of timestamp)
static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)

Number wrapper class:
// Autoboxing/unboxing
*Integer.parseInt(String s); // Convert string to int
Integer.parseInt(String s, int radix); // Convert other base strings into an int
Integer.toBinaryString(int i); // Convert an int value to a binary string
Integer.toOctalString(int i); // Convert an int to an octal string
Integer.toHexString(int i); / / Convert an int to a hexadecimal string

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325302436&siteId=291194637
Recommended