关于抽象方法问题 hello hellol = new hello();//应该是useabs hellol = new useabs(); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 new hello();此乃何方神圣? new hello();该类在哪呀? abstract class hellobase{ private int i; abstract void base();}public class useabs extends hellobase { private String i; public void base() { System.out.println("true"); } public static void main(String[] args) { hellobase hello1=new hellobase(); hello1=new useabs(); try { hello1.base(); } catch (AbstractMethodError e) { System.out.println("false;"); } }}你试一下这个就明白了,因为是虚函数,所以必须重新覆盖所有虚方法后才能使用,声明时也必须是先声明一个虚对象的引用,再把实例地址付值给他! 没有hello这个类,当然报错~~~ hellobase hello1=new useabs();就行了 Java技术网站大全 java 程序编译没出错 运行时出错 功能无法实现 Socket多线程同步问题 javax.swing.JPopupMenu 不能自动消失 java程序运行报错 百分求教关于socket长连接的问题 请问大虾们:报这样的错是怎么回事啊? 初学者求救 对象的建立 大家看看这是什么异常!!! 如何用java程序来拨号 如何把文件内容一次都读到一个字符数组中? j2se j2ee ejb jms之间是怎么个关系呢??
该类在哪呀?
{
private int i;
abstract void base();
}
public class useabs extends hellobase
{
private String i; public void base()
{
System.out.println("true");
}
public static void main(String[] args)
{
hellobase hello1=new hellobase();
hello1=new useabs();
try
{
hello1.base();
}
catch (AbstractMethodError e)
{
System.out.println("false;");
}
}
}
你试一下这个就明白了,因为是虚函数,所以必须重新覆盖所有虚方法后才能使用,声明时也必须是先声明一个虚对象的引用,再把实例地址付值给他!