现在的位置: 首页 > 综合 > 正文

Think in java 答案_Chapter 4_Exercise 8

2013年03月20日 ⁄ 综合 ⁄ 共 611字 ⁄ 字号 评论关闭
/****************** 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.

 

抱歉!评论已关闭.