如何在eclipse中生成构造函数 [英] how to generate constructors in eclipse

查看:127
本文介绍了如何在eclipse中生成构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类A和BM扩展A.现在我想创建一个使用eclipse的代码生成选项的B的构造函数,它接受B的所有字段的参数和设置值(我的意思是它也应该设置从A继承的字段)



是否有任何快捷方式在eclipse中生成这样的代码?

解决方案

右键单击编辑器,然后单击源 - >使用字段生成构造函数。您可以选择要使用的超级构造函数,还可以选择要添加到构造函数中的实例变量。


I have a class A and B.M extends A. Now I want a create a constructor of B using code generation option of eclipse which accepts parameters and set values of all fields of B (I mean it should also set fields inherited from A).

Is there any shortcut to generate such code in eclipse?

解决方案

Right click in the editor and click "Source -> Generate Constructor using Fields". You can select the super constructor to use and also select instance variables to add to the constructor.

这篇关于如何在eclipse中生成构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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