Think in java 答案

    技术2022-05-11  128

    /****************** Exercise 8 ****************** * Create a class without a constructor, and then * create an object of that class in main() to * verify that the default constructor is * automatically synthesized. ***********************************************/ public class E08_SynthesizedConstructor {   public static void main(String args[]) {     // Call the synthesized default constructor     // for this class:     new E08_SynthesizedConstructor();   } }

    //+M java E08_SynthesizedConstructor

    **Since the constructor can be called, it must have been created, even if you can’t see it.

    **Since I’m not using the reference that comes back from the new expression, I don’t need to create a variable to hold it.

     

    最新回复(0)