1. static function
It is resolved statically based on the class, not like instance method which are resolved based on object.
1.1 can't be overridden
1.2 can only use static variable and static function
1.3 can't use this or super
2. static variable
It is a variable that has been allocated statically—whose lifetime or "extent" extends across the entire run of the program
Example: There is no reason to have a declaration such as
private final int NUMBER = 10;
//If it cannot change, there is no point having one copy per instance.
//Better to us private final static int NUMBER = 10
3. static class
It can only be used to declare a inner class
Example:
public class StaticCls {
public static void main(String[] args) {
OuterCls.InnerCls oi = new OuterCls.InnerCls();
}
}
class OuterCls {
public static class InnerCls {
InnerCls() {
System.out.println("InnerCls");
}
}
}