编译器会自动帮你创建构造器;如果已经有了构造器(无论是否有参数),编译器将不再为你创建构造器

    1. class Bird {}
    2. public class DefaultConstructor {
    3. public static void main(String[] args) {
    4. Bird b = new Bird(); // Default!
    5. }
    6. }
    7. class Bird2 {
    8. Bird2(int i) {}
    9. Bird2(double d) {}
    10. }
    11. public class NoSynthesis {
    12. public static void main(String[] args) {
    13. //Bird2 b = new Bird2(); // No default
    14. Bird2 b2 = new Bird2(1);
    15. Bird2 b3 = new Bird2(1.0);
    16. }
    17. }