1. public class CameraController {
    2. private String basename = "base";
    3. public CameraController() {
    4. name();
    5. }
    6. public void name() {
    7. System.out.println(basename);
    8. }
    9. static class sub extends CameraController {
    10. private String basename = "sub";
    11. public sub() {
    12. name();
    13. }
    14. public void name() {
    15. System.out.println(basename);
    16. }
    17. }
    18. public static void main(String[] args) {
    19. CameraController b = new sub();
    20. }
    21. }
    22. 猜猜结果是啥<br>
    23. 需要考虑重写,实例化顺序;<br>