First, the data type
1.java, all numeric types account for the number of bytes and platform-independent, there is no unsigned type in Java
2. For overflow floating-point type, expressed in Nan. Double.isnan (x)
3.char type accounted for 2 bytes
4. Boolean types cannot be converted to integers, avoiding the IF (x=3) problem in C + +, if the conversion is possible. :
5.&& | | Will short circuit
6. Two operands if one is a double, the other is converted to double
If one is float, the other will turn into a float
If one is long, the other is converted to long;
Second, string
A 1.java string is a sequence of Unicode characters.
2.1 A String class object is an immutable string that can be modified to refer to another string.
Pros: The compiler can let strings be shared, with various strings in the common storage pool. Only string constants are shared, and the results of operations such as + or substring are not shared;
equals compares content, and = = Compares location only
2.2 Common APIs:
CharAt (), CompareTo () Endwith () equals () Equalsignorecase () indexOf ()
LastIndexOf () Length () Replace () substring () toLowerCase () toUpperCase () trim ()
3. Building a String
StringBuilder high efficiency, suitable for single thread
StringBuffer low efficiency, suitable for multi-threaded
4.Scanner
Scanner (InputStream in) Scanner (new File ()) Scanner (String str)
Nextline () line next () Word Nextint () nextdouble () Hasnext ()
PrintWriter (file f) constructs a printwriter that writes to a file
Four, array
1.array.copyof (oldarray,length) is often used for expansion, and arrays are allocated on the heap.
2.array.tostring (type[] a)
3.array.sort () BinarySearch () Fill ()
Basic Java Knowledge