有没有办法在 Eclipse 中自动生成 getter 和 setter? [英] Is there a way to automatically generate getters and setters in Eclipse?

查看:34
本文介绍了有没有办法在 Eclipse 中自动生成 getter 和 setter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个新的 Android 项目 (Java),并创建了一个包含大量变量的对象.由于我打算为所有这些添加 getter 和 setter,我想知道:Eclipse 中是否有快捷方式可以在给定的类中自动生成 getter 和 setter?

I am working on a new Android project (Java), and created an Object with a large number of variables. Since I am planning to add getters and setters for all of them, I was wondering: is there a shortcut in Eclipse for automatically generating the getters and setters in a given class?

推荐答案

在所需类的源代码窗口中调出上下文菜单(即右键单击).然后选择Source子菜单;从该菜单中选择 Generate Getters and Setters... 将出现一个向导窗口.

Bring up the context menu (i.e. right click) in the source code window of the desired class. Then select the Source submenu; from that menu selecting Generate Getters and Setters... will cause a wizard window to appear.

源代码 ->生成 Getter 和 Setter...

选择要为其创建 getter 和 setter 的变量,然后单击 OK.

Select the variables you wish to create getters and setters for and click OK.

这篇关于有没有办法在 Eclipse 中自动生成 getter 和 setter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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