package lzhw;public class super
{
int a=10;
void hi()
{
System.out.println("hello");
}
class sub extends super
{
int b=20;
void hi()
{
System.out.println("hi");
}
void bye()
{
System.out.println("bye");
}
}
public class super{
public static void main(String[] args)
{
super ob=new sub();
ob.a=20;
ob.hi();
}
}
}
{
int a=10;
void hi()
{
System.out.println("hello");
}
class sub extends super
{
int b=20;
void hi()
{
System.out.println("hi");
}
void bye()
{
System.out.println("bye");
}
}
public class super{
public static void main(String[] args)
{
super ob=new sub();
ob.a=20;
ob.hi();
}
}
}
{
……
public static void main(String[] args)
{
super ob=new sub();
ob.a=20;
ob.hi(); 不止是super是关键字,不能作为类名哦
你创建内部类对象也不对
super supe=new super();
supe.sub ob=supe.new sub(); 而sub extends super 扩展了外部类
void hi()
方法相当于重载了
LZ要是把上面的错误都改了
应该可以
package lzhw; class Super
{
int a=10;
void hi()
{
System.out.println("hello");
}
}
class sub extends Super
{
int b=20;
void hi()
{
System.out.println("hi");
}
void bye()
{
System.out.println("bye");
}
}
public class Test{
public static void main(String[] args)
{
Super ob=new sub();
ob.a=20;
ob.hi(); }
}
错误2 内部类调用错误。