public class A//父类
{
public static String str = "静态属性";
public String name = "非静态属性";
public static void sing()
{
System.out.println("静态方法");
}
public void run()
{
System.out.println("非静态方法");
}
}
package com.etc;
public class B extends A //子类B
{
public static String str = "B该改写后的静态属性";
public String name ="B改写后的非静态属性";
public static void sing()
{
System.out.println("B改写后的静态方法");
}
}
package com.etc;
public class C extends A //子类C继承A中的所有属性和方法
{
}
package com.etc; |
|