视
视觉音乐
Unregistered / Unconfirmed
GUEST, unregistred user!
初学Java,继承的问题,请指点一下:
****************************************************
Book类:
package com.wrox.library;
public class Book
{
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Book(String title) {
this.title = title;
}
}
****************************************************
ChildrenBook类,从Book继承:
package com.wrox.library;
public class ChildrenBook extends Book
{
private int minimumAge;
public int getMinimumAge() {
return minimumAge;
}
public void setMinimumAge(int a) {
minimumAge = a;
}
public ChildrenBook(){
super();
}
public ChildrenBook(String title) {
super(title);
}
};
****************************************************
我用的是Jsp,两个类都放在WEB-INF/classes/com/wrox/library目录下,Book.java可以
编译通过。ChildrenBook.java编译时出错。错误提示在第一句:
public class ChildrenBook extends Book 的Book下面。
****************************************************
Book类:
package com.wrox.library;
public class Book
{
private String title;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Book(String title) {
this.title = title;
}
}
****************************************************
ChildrenBook类,从Book继承:
package com.wrox.library;
public class ChildrenBook extends Book
{
private int minimumAge;
public int getMinimumAge() {
return minimumAge;
}
public void setMinimumAge(int a) {
minimumAge = a;
}
public ChildrenBook(){
super();
}
public ChildrenBook(String title) {
super(title);
}
};
****************************************************
我用的是Jsp,两个类都放在WEB-INF/classes/com/wrox/library目录下,Book.java可以
编译通过。ChildrenBook.java编译时出错。错误提示在第一句:
public class ChildrenBook extends Book 的Book下面。