什么时候在java中调用构造函数? [英] When does the Constructor gets called in java?

查看:237
本文介绍了什么时候在java中调用构造函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时调用构造函数?


  1. 在创建对象之前。

  2. 在对象创建期间。

  3. 创建对象后。


推荐答案

分配对象内存,初始化具有初始值的字段变量,然后调用构造函数,但其​​代码在对象超类的构造函数代码之后执行。

The object memory is allocated, the field variables with initial values are initialized, and then the constructor is called, but its code is executed after the constructor code of the object super class.

这篇关于什么时候在java中调用构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆