Java foundation 3 - program control statement, class, object and method

xiaoxiao2021-04-04  284

Program control statement

1. Similar to the C language, note that if statement conditions must be Boolean type, 2, switch statement, the expression can be char, BYTE, SHORT, INT type, Break statement is the same as the C language. in case

A CASE statement is not ended in Break, then execution will enter the next case statement sequence, of course, the premise is that the statement must exist. 3, for loop Similar to C language, pay attention to the conditional part must add enhanced for loops to the Boolean value JDK5.0, for-Each form, from the head to the tails, the format is as follows: for (Type ITR-VAR: Collection Statement-block; In addition to the array, it can iterate the collection content defined by Collectes Framework. 4, while loop, do-while loop, similar C, control conditions must be Boolean5, Break statement, Break label; you can jump out of multiple loops. The limit can only be jumped to the outside of the code block containing the Break code. 6. Continue statement, a mark of Continue Label; jump to the peripheral mark to continue.

Class, objects and methods

1, main method, program running, applet does not require Main () 2, New operator for object dynamic allocation of memory 3, when assigning reference variables, does not generate copy 4, finalize method, recycling this class in Java This method is called when an object is called. In the finalize method, specify before being destroyed

The action that must be performed. But programmers generally don't know when to call Finalize (), which is automatically called by the garbage collector. 5, THIS keyword, similar to C ;

转载请注明原文地址:https://www.9cbs.com/read-131966.html

New Post(0)