Java modifiers can be divided into two types
- Accessible modifiers
- Non-accessible modifiers
Using modifiers, you can use the definition of the class, method, variable
Accessible modifiers
- Package visible, default, no modifiers required
- Can only be visible by class (private)
- All visible (public)
- Can only be visible to the current package and all classes (protected)
Non-accessible control characters
- static modifier for creating class methods and variables Statics
- Final modifier for completing class, method, and variable implementations final
- Abstract modifier for creating abstract classes and methods
- The synchronized and volatile modifiers are used for threading.
Java operators
- Arithmetic Operators (arithmetic operator)
- Relational Operators (relational operator)
- Bitwise Operators (bitwise operator)
- Logical Operators (logical operator)
- Assignment Operators (Assignment operator)
- Misc Operators (Other operators)
算术运算符- +- -- *- /- % (模)- ++- --
关系运算符- == - !=- >- <- <=- >=
Bitwise operators
a = 0011 1100b = 0000 1101a&b = 0000 1100(与,都为1为true)a|b = 0011 1101(或,有1就是true)a^b = 0011 0001(异或,不同就是true)~a = 1100 0011(取反)a<<2 左移扩大 1111 0000a>>2 右移缩小0000 1111
logical operators
- A && B 都真为真- A||B有真为真- !A 取反
Assignment operators
- =- +=- -=- *=- /=- %=- >>=- &=- ^=- |=
Ternary operators
- varible x =(expression)?value if true:value if false
instanceof
( Object reference variable ) instanceof (class/interface type)
public class Test { public static void main(String args[]) { String name = "James"; // following will return true since name is type of String boolean result = name instanceof String; System.out.println( result ); }}
Priority table
Java modifiers and basic operators