final 关键字:用来修饰类,方法,成员变量,局部变量 表示最终的不可变的 1.final修饰一个类 表示当前的类不能有子类,也就是不能将一个类作为父类 格式: public final class 类名称 { class body } 一个类如果是final的,那么其中所有成员方法都不能被覆盖重写(因为没有子类),但是该类可以有父类 2.final关键字修饰成员方法 这个方法就是最终方法,也就是该类的子类不能覆盖重写这个方法 对于类.方法来说abstract.final不能同时使用,因为他们…
class class UIRect:public RECT { public: UIRect(LONG leftT = 0, LONG topT = 0, LONG rightT = 0, LONG bottomT = 0) { left = leftT; top = topT; right = rightT; bottom = bottomT; } int GetWidth() const { return right - left; } int GetHeight() const { re…
定义 静态成员:又称类成员,使用static修饰符的方法和变量: 非静态成员:又称实例成员,未使用static修饰符的方法和变量. 结论 注:jdk1.8 测试源码 public class Main { private int x = 34; // 非静态变量 private static int a = 1; // 静态变量 private static int b = a; //[√] 静态变量调用静态变量 private static int c = getA(); //[√] 静态变量…