package first;
interface Car {
void lighting();
}
public class Test implements Car{ @Override public void lighting() { // TODO Auto-generated method stub } public void ss(){ System.out.println("haha"); } public static void main(String[] args) { Car test = new Test(); ((Test) test).ss(); } }
强制转换成子类,能避免向上转型造成的属性、方法的丢失。