public abstract class Number implements java.io.Serializable {
Number类有修饰符 abstract 。表明Number类定义了一些方法,并没有具体实现,需要子类自己实现,关于abstract ,quaro上一个答案写的很清晰:
The “abstract” Keyword
- The keyword
abstract
can be used on classe declaration. For exampleabstract MyClassX (…);
. - The keyword
abstract
can be used on method declaration. For exampleabstract int f (…);
. - When a class is declared
abstract
, it cannot be instantiated. - When a method is declared
abstract
, it cannot have definition. - Only abstract classes can have abstract methods. Abstract class does not necessarily require its methods to be all abstract.
时间: 2024-10-12 19:37:03