"Crazy JAVA Lecture Notes" 1

table of Contents

 

Garbage collection mechanism

Comment

type of data

Operator


Garbage collection mechanism

  1. Memory leak: If some allocated memory is not recovered in time, it will slow down the running speed of the system and even lead to program paralysis. This phenomenon is called memory leak.

  2. Show two main disadvantages of garbage collection:

    1) The program forgets to reclaim useless memory in time, causing memory leaks and reducing system performance.

    2) The program erroneously reclaims the memory of the program's core class library, causing the system to crash.

  3. Advantages of garbage collection mechanism:

    1) Improve programming efficiency well;

    2) Protect the integrity of the program.

    Comment

  4. There are three types of java comments: single-line comments; multi-line comments; documentation comments.

    Document note: The form is (/**......*/)

    Documentation comments are used to generate API documentation, and API documentation is mainly used to explain the functions of classes, methods, and member variables. Therefore, by default, the javadoc tool only processes documentation comments before public or protected classes, interfaces, methods, member variables, constructors, and internal classes.

    Give a chestnut :

    image

  5. All keywords in java are lowercase.

    type of data

  6. The types supported by the java language are divided into two categories: basic types and reference types.

    1) Basic types: boolean type and numeric type (integer type and floating point type);

    2) Reference types (equivalent to pointers): classes, interfaces, arrays, and a special null type.

  7. Among the basic data types, a string is not a basic data type , and a string is a class, that is, a reference data type.

  8. There are three representations for character values:

    1) A single character, eg:'A', '0';

    2) Express the special character value through escape characters, eg:'\n','\t';

    3) Directly use Unicode value to represent character value, eg:'\u0005'.

     

Give a chestnut:

image

turn out:

 

image

 

It is worth noting that: the single quotes, double quotes and backslashes in the java language have special uses. If these special characters are included in a string, the escape character representation should be used. eg: "c:\\codes", only when you write two backslashes, Java will treat the first backslash as an escape character, and the latter is the real backslash.

 

9. Floating point type:

1) Two representation forms: decimal number form and scientific notation form.

2) The floating-point type of java language is double by default. If you want java to treat a floating-point number as a float type, you should add f or F after the value.

3) Three special floating-point numbers: positive infinity (POSITIVE_INFINITY), negative infinity (NEGATIVE_INFINITY), and not a number (NFN), used to indicate overflow or error.

All positive infinity values ​​are equal, and all negative infinity values ​​are also equal. But non-number and any number do not want to wait, and non-number and non-number are not equal.

Note: Only the floating-point number divided by 0 can get positive or negative infinity, because the Java language will automatically treat 0 (integer) as 0.0 (floating point). Dividing an integer by 0 will throw an exception.

Give a chestnut:

image

 

The following is an error to illustrate the correct representation of floating point numbers

image

The result after commenting out the line change is as follows:

image

The last one is the throwing of an exception.

4) Boolean value can only be true or false.

Operator

10. The assignment operator supports continuous assignment. eg: a=b=c=5;

11. There are 7 bitwise operators supported by java:

    1) & and

    2)| or

    3) ~ Not

    4) ^ Bitwise XOR

    5) << shift left

    6) >> right shift

    7) >>> unsigned right shift

Give a chestnut:

image

The results are as follows:

image

note:

The shift operation here should take into account the numeric type, if it is an int type, 32 bits, the number greater than 32 should be the remainder. Unsigned shift note that the high bit is filled with the original sign bit. In addition, the operation of negative numbers is in the form of complement.

 

image

 

I hope you can criticize and correct me if you don't have it!

Guess you like

Origin blog.csdn.net/allein_STR/article/details/113984677