SCJP study notes (2)

xiaoxiao2021-03-06  57

1. ~ Refueling the integer, for example ~ i = -i-1 = - (i 1)

The 2.Math.ceil () method is hierarchically, for example, CEIL (0.5d) = 1.0; CEIL (-0.5d) = - 0.0;

Math.floor () method, with negative direction of operands, such as floor (0.5d) = 0.0; floor (-0.5d) = - 0.0;

Math.Round () method, with the operand, forward 5 into, negative direction 6. Round (5.5d) = 6.0; Round (-5.6) = - 6.0; Round (-5.5) = - 5.0;

Math.max (VAL1, VAL2), MIN (VAL1, VAL2) can operate any digital variable and automatically return to a precision.

Math.random () method will produce a random number, which ranges from 0-1.

Round's return value is an INT type, other ABS, CEIL, FLOOR, RANDOM, SIN, COS, TAN, and SQAT return values ​​are Double type.

3. The value of (4.4e3) is 4.4 * 10 3 times

4. Initialization of class: Surrounded by {} in the definition of the class is initializer, its initialization is before the construction method. Initializer is divided into static (running when the class is loaded, only once), is not static (multiple run, each time the class is loaded)

5. && with, || or,! None, ^ Different or (the two are true),

Bills &, | or,! Non, ^

6. Displacement operation, >> The right shift of the symbol is equivalent to the right shift of the entire 2, >>> without a symbol (acting on bitmap operation, no measurement significance for negative numbers), << (without symbol Left shift equivalent to 2)

7. Equals can determine two considerable types of objects, and the value is equal, if the object type is different. == (When the basic data type is used), it can be judged that when the two objects point to the same address, it is true. If this type is true. String S1 = "aa"; string s2 = "aa"; S1 == S2, true, string s1 = new string ("aa"); String S2 = "aa"; S1 == S2, is false. If the two object types are different, compile errors will be generated.

8. The packaging class and string have similar characteristics, and they cannot be changed after generation.

9. The non-static method or variable cannot be accessed in the static method. If it is an instance of the object, the non-static method and variable can be accessed.

10. When defining a method, you can use the Throws declaration to throw an exception, and you can use throw to throw an exception to thrown during the run. Throwing an exception must be captured with try, catch, finally statement, try to match Catch or Finally, but you can use Catch to capture when defining methods, but must use when performing an exception statement Catch to capture, otherwise it will not be able to compile if the RuntimeException exception is not predicted.

11.yeld (), Sleep () is a static method of the Thread class, which must be performed by a thread being executed. If a certain class inherits Thread, it can be called directly after the public void run () method is implemented. 12. If multiple processes of the same class will share the variables of this class.

13. The number is saved in the form of complement, and the positive complement is the positive number, the negative complement of the complement, and the other bit take anti- 1. If the original code of -7 is 10000111, Completion is 1111000 1 = 11111001

14.instanceOf: VAR InstanceOf C, where c can be interfaces, classes, or arrays, as long as VAR inherit or implements or belongs to the related class, interface, arrays return true, but VAR must be objects existing in memory, otherwise returns false.

15.? : Alignment is normal when calculated, int A = 5; (a <5)? 9.9: 9; the result will be 9.0

16. StringBuffer and String Differences, StringBuffer cannot directly assign a string value, such as StringBuffer = "abcd" is not allowed.

17. Assert: assert: assert syntax, (1) Assert Exp1; (2) Assert Exp1: exp2; Exp1 is a logical expression, which is a Message. (3) Artificial throwing a Throw new asserterror (), there are six basic types of parameters (non-Byte, Short), Object, and non-parametric constructors. Enable assert, javac -source1.4 class.java; java -ea class; (start assertion java -ea: package ... Class, you will add omitting, if you have a message, if you have a message, if you have an outline of a specific class. Or disabling assertions must be written in a full name. For example: java -ea: package.ibm ... -da: package.ibm.myclass class, Assert is not suitable for use in a specific function, for example: Assert XXX.Remove (); Is not appropriate because the program Assert may not be executed.

18.Package: If you are in the program definition package, you must put the class files in the package in the directory named directory, for example: package a; public class b {} must put the b.class file in the directory A If you want to call the contents in B.Class in other different packages, you must first set the superior directory of the A directory to ClassPath, then use import a; or write the full path call A.BS. If the call file itself belongs to a package, you should use the Javac-CP parent catory class file, (compile operation method) JAVAC package name. Class name .java, Java package name. Class name

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

New Post(0)