Java中的继承

来源:百度知道 编辑:UC知道 时间:2024/05/30 22:30:43
import java.lang.*;
public class twistered extends Math {
public int c;
public twistered(int c) {
this.c=c;
}

public static void main(String args[]){
twistered a=new twistered(30);
}

}到底哪里出错了啊

Math类 被final修饰,不准被继承
final类似于 C中的 const关键字
被final修饰的变量不能被更改,就是常量了
被final修饰的类不能被其他的类继承,这是基本知识,自己查书去

系统提示错误:The type Twistered cannot subclass the final class Math
具体的我也不清楚,没遇到过!另外提醒下:类名都大写。

一楼 正解