Public classtext2{ Public Static voidMain (string[] args) {//Constant PoolString S1= "ABC"; String S2= "ABC"; System.out.println (S1==S2);//true//S1 and S2 point to the same object, all pointing to the same memory addressString S3=NewString ("abc");//re-opening an area in memory spaceString S4 =NewString ("abc");//re-opening an area in memory spaceSystem.out.println (S3==S4);//false//S3 and S4 Point different, point to the memory address is not the sameSystem.out.println (S3.equals (S4)); //true//Compare the contents of the two strings S3 and S4, both of which are ABC }}
Packing class:
Integer.parseint ();
BYTE---Byte
Short---short
int---Integer
Long---long
Float---float
Double---double
Boolean---Boolean
Char---Character
Public classtext2{ Public Static voidMain (string[] args) {//Packaging class, there are corresponding methodsSystem.out.println (Integer.min_value); System.out.println (Integer.max_value); System.out.println (Byte.min_value); // -System.out.println (Byte.max_value);//127System.out.println (Long.min_value); System.out.println (Long.max_value); System.out.println (Short.min_value); //-32768System.out.println (Short.max_value);//32767System.out.println (Float.min_value); System.out.println (Float.max_value); System.out.println (Double.min_value); System.out.println (Double.max_value); System.out.println (Integer.parseint ("56"));//56, you need to pay attention to the corresponding method name hereSystem.out.println (Float.parsefloat ("56"));//56.0System.out.println (Float.parsefloat ("12.34"));//12.34 }}
Processing of strings:
equals between strings
String str = "..." and "..";
Str.length ();
Str.trim ();
Str.charat (int i);
Str.contains (charsequence s);
Str.startswith (String s);
Str.endswith (String s);
Replace (char O, char N);
Replace (charsequence O, charsequence N);
Split (String s);
toUpperCase ();
toLowerCase ();
ValueOf (any args);
Str.indexof (String s);
Str.lastindexof (String s);
str.substring (int i);
str.substring (int A, int b);
Public classtext2{ Public Static voidMain (string[] args) {String str= "A New World a new start"; System.out.println (Str.length ()); //The output value is 25, including spaces on both sides, which returns the length of the entire stringSystem.out.println (Str.trim ());//The output value is "a new World a new start", which is to remove spaces on both sides of the stringSystem.out.println (Str.trim (). Length ());//The output value is 23, which means that the length of the entire string is returned after the space is removed.System.out.println (Str.charat (3));//The output value is N, which is the character that is taken out of the specified index position in the stringSystem.out.println (Str.contains ("new"));//The output value is true, which is to determine whether a string contains another string that you specify.//true if contained, not included, falseSystem.out.println (Str.contains ("ABC"));//output value is FalseSystem.out.println (Str.startswith ("QQ"));//The output value is false, which is to determine whether a string starts with another string,//This string starts with a space instead of starting with QQ, so the result is falseSystem.out.println (Str.endswith ("QQ"));//The output value is false, which is to determine whether a string ends with another string,//This string ends with a space, not the end of QQ, so the result is falseSystem.out.println (Str.replace (' A ', ' B ');//The output value is "b New World B New STBRT",//which is to replace all a in the string with B.System.out.println (Str.replace ("New", "old");//The output value is "a Old World a old start"//that is, the character or string specified in the replacement stringstring[] STRs= Str.split ("");//Note and string[] STRs = Str.split ("", 3); The differenceSystem.out.println (strs.length);//the output value is 7, and the last space is omitted for(String s:strs) {System.out.println (s); } System.out.println (Str.touppercase ());//converts a string to uppercase, which is "a new World a new START"System.out.println (Str.tolowercase ());//convert string to lowercase, "a new World a new start"System.out.println (string.valueof (6));//toString ();System.out.println (Str.indexof ("new"));//The position of the substring in the first occurrence of the string, with a output value of 3System.out.println (Str.lastindexof ("new"));//The last occurrence of the substring in the string, the output value isSystem.out.println (str.substring (5));//The truncated string contains a character with an index of 5, and the output value is W world a new start
// A character that starts from the first digit, until the second digit, but does not contain the position of the second digit, that is, from 5th to 7th, with the output value W w } }
Array, number, string processing