有没有办法在 Eclipse 中自动生成 getter 和 setter?

编程入门 行业动态 更新时间:2024-10-28 16:26: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?

本文发布于:2023-11-03 14:23:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555356.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   自动生成   setter   Eclipse   getter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!