java 新手提问
import java.util.*;
public class Welcome {
public static void main(String[] args) {
new Person().printPerson();//这两行为什么会错
new Student().printPerson();
}
class Student extends Person{
@Override
public String getInfo(){
return "student";
}
}
class Person{
public String getInfo(){
return "person";
}
public void printPerson(){
System.out.println(getInfo());
}
}
}为什么会错呢。我是按书上打上去的
另外我换成这些之后还是不对
Person p = new Person();
Student s = new Student();
p.printPerson();
s.printPerson();
错误原因都是这些
No enclosing instance of type Welcome is accessible. Must qualify the allocation with an enclosing instance of type Welcome (e.g. x.new A()
where x is an instance of Welcome).
...全文
相关推荐
Java学习心得分享
Java学习心得,JAVA是比较热门,但我们自己不能头脑发热。我觉得所有初学者要学好JAVA或C或UNIX等任何一门计算机技术,一定要做到
浙江联通ParlayX开发实例,Java
浙江联通ParlayX开发实例,Java 新手入门的好东东
DevCloud新手课堂之两步体验eclipse操作代码仓库.docx
DevCloud新手课堂之两步体验eclipse操作代码仓库.docx
JAVA 初学者 200多个源码
提供了初学者200多个源码文件,可以仿照学习,促使你上进学习,能力提高更快。。
java学习资料 对初学者很有帮助
java学习资料和java帮助文档 如:教你如何学习java,一些常用论坛


Java SE
