small tips

1. Basic data types
• Numerical
        integer type (byte, short, int, long)
                  Floating point type (float, double)
• Character type: (char)
• Boolean (boolean)


2. Reference data type
• Class (class)
• Interface (interface)
• Array ([])


3.== and equals
• == Returns true if the values ​​are equal when comparing primitive data types. Returns true
when comparing reference data types if the same object is referenced
• Arrays: 1. Arrays.equals(a,b), Static method, when a and b have the same length and the corresponding position elements are equal     
                            or refer to the same object, return true
           2. a.equals(b), when a and b refer to the same object, return true.                         • String: str1.equals(str2), returns true
when str1 and str2 refer to the same object or have the same content      .


4. Input
 1. Use the Scanner class:
(1) Use the java.util package. import java.util.*;

(2) Construct the Scanner class object, which is attached to the standard input stream System.in.
         Scanner s = new Scanner(System.in);
(3) Commonly used next() method series:
• nextInt(): input integer
• nextLine(): input string     
• nextDouble(): input double precision number     
• next() : Input string (separated by spaces).


5. Output format control:


6. Member variable modifiers

7. Loading order:
1) Static first: Members and code blocks modified with static are executed in order from top to bottom when the class is loaded for the first time.
2) Post non-static: The code block is executed before the constructor, and the code in it whether it is static or non-method is executed when it is called.
3) First parent class:
4) After subclass; in short, when loading a class, all members within it follow the order of static first and then non-static.
1. Parent class static code block2
. Child class static code block3
. Parent class construction code block4
. Parent class constructor5.
Subclass construction code block6
. Subclass constructor    
summary: static first, then non-static, parent first Subclass after class.

 

 

Guess you like

Origin blog.csdn.net/weixin_52575498/article/details/123201580