java的有参方法

2025-04-02 21:58:05
推荐回答(2个)
回答1:

系统不会在调用有参构造方法的时候自动调用无参构造方法。需要自己手工实现 1、在有参构造函数中调用无参构造函数 例如: public class TA{ public TA(){//定义无参构造函数 } public TA(int a){//定义有参构造函数 this();//调用无参构造函数 }}

回答2:

custArray数组里存储的是Customer 对象的引用。

Customer customer = custArray[i] 这个就是把引用赋给customer。