Java basic notes 3, java basic notes
Keywords of the basic composition of Java language
Words with special meanings granted by java
All letters in the keyword are in lowercase.
Keywords used to define data types: class, interface, byte, short, int, long, float, double, char, boolean, void.
Keywords used to define data type values: true, false, and null.
Keywords used to define Process Control: if, else, switch, case, default, while, do, for, break, continue, return.
Keywords used to define access permission modifiers: private, protected, and public.
Keywords used to define classes, functions, and variable modifiers: abstract, final, static, and synchronized.
Keywords used to define the relationship between classes: extends and implements.
Defines instance creation and reference, and determines the keywords of the instance: new, this, super, instanceof.
Keyword used for exception handling: try, catch, finally, throw, and throws.
Keyword used for the package: package and import.
Other modifiers include native, strictfp, transient, volatile, and assert.
Identifier
Some custom names in the program. It consists of 26 uppercase/lowercase letters, numbers 0-9, and symbols _ $.
Rule for defining valid identifiers: A number cannot start with or use a keyword.
Java is case-sensitive. when naming, it should be meaningful to improve readability.
Naming rules in Java:
Package name: when multiple words are made up, all letters are in lower case. Xxxyyyzzz
Class Name Interface Name: when multiple words are made up, the first letter of all words is capitalized. XxxYyyZzz
Variable name and function name: when multiple words are made up, the first character is the first character. The second character starts to uppercase. XxxYyyZzz
Constant name: All letters are in upper case. When multiple words exist, each word is connected by an underscore. XXX_YYY_ZZZ
Note
Single line, multi-line, document comment
Constants and variable constants indicate unchangeable values.
Classification of constants in Java:
Integer constant: All integers
Decimal constant: All decimal places
Boolean constants: only true and false
Character constant: identifies a number, letter, or symbol with single quotation marks.
String constant: identifies one or more characters with double quotation marks.
Null constant: Only one value is null.
For integers: java has three forms: decimal, octal, and hexadecimal.
Basic hexadecimal conversion
Decimal Binary Conversion:
Convert decimal to binary, divide by 2 to get the remainder
Convert binary to decimal, multiply by the power of 2
Decimal octal Conversion
Hexadecimal conversion
Negative binary representation:
Corresponding positive number binary decimal 1
Variable Concept
Operator
Statement
Function
Array