I just had an interview where one of the questions was something like "Describe 5 ways to use the static keyword in Java." I could only think of 2 on the spot, and afterwards I found 2 more. What is the 5th?
static import (since java 1.5):
import static my.package.MyClass.*;
Would declaring a static interface
be considered a class in this instance? If not then there's another use.
要更改另一个静态方法/变量的行为。
常量 - 静态final(与#1真的相同,但可以考虑单独使用)
create a static block
static
{
// Do some static work
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.