Keyword
static, final, volatile
static vs. final
The static member can be accessed before the class object is created.
`static` is used to define the class member that can be used independently of any object of that class
Final keyword is used to declare, a constant variable, a method which can not be overridden and a class that can not be inherited.
volatile
在写入 volatile 变量时,之前写的(在缓存里的)变量都会被强制写入内存中
在读取 volatile 变量时,之前读的(在缓存里的)变量都会重新从内在中读取
Last updated
Was this helpful?