JAVA-Little knowledge
1. The difference between int and integer
Integer is the wrapper class for int, and int is a basic data type of Java
An integer variable must be instantiated before it can be used, and the int variable does not need
An integer is actually a reference to an object, and when new is an integer, it actually generates a pointer to the object, while int stores the data value directly
The default value for integer is the default value of Null,int is 0
Because the integer variable is actually a reference to an integer object, the two integer variables generated by new are never equal (because new generates two objects with different memory addresses).
Integer i = new integer (+); Integer j = new Integer (+); System.out.print (i = = j); False
Integer is the wrapper class for int, and int is a basic data type of Java
When an integer variable is compared to an int variable, the result is true if the value of the two variable is equal (because the wrapper class integer and the base data type int are compared, the Java is automatically wrapped to int and then compared, and actually becomes a comparison of two int variables)
The result is false when a non-new generated integer variable is compared to a variable generated by the new Integer (). (Because a non-new integer variable points to an object in a Java constant pool, the new Integer () generates a variable that points to the new object in the heap, and the address in memory is different)
Integer i = new integer (+); Integer j = +; System.out.print (i = = j); False
2. String type
Digital---convert to-->string:string a = "" +num;
String type cannot be used with str[i], but Str.charat (i)
Haystack.substring (I,I+L2). Equals (needle)// takes a substring and determines whether it equals needle
return new StringBuffer (s). Reverse (). toString (); Reverse Convert string
It is thread-safe for StringBuffer to manipulate the string itself in memory that is better than string.
Conversion between StringBuffer and string:
String s = "abc"; StringBuffer sb1 = new StringBuffer ("123"); StringBuffer SB2 = new StringBuffer (s); The string is converted to StringBuffer string S1 = sb1.tostring (); StringBuffer Convert to String
3. Binary conversion
Java.lang.Integer This API package has the function of the binary conversion:
These 3 functions can convert decimal integers to 26 or 16, octal numbers
public static string tobinarystring (int i) //String a = Integer.tobinarystring (n) public static string Tohexstri ng (int i) //String a = Integer.tohexstring (n) public static string tooctalstring (int i) //String a = Integer . tooctalstring (N)
Stack st = new stack ();
4. Stack
Statement: