A extends B.B b = new A();A a = (A) b.以上是没有问题的。其实在调用paint(Graphics oldg)时所传入的参数oldg本身就是Graphics2D对象。你可以在方法的开始加上System.out.println(oldg);就明白了。