Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有用于在 Eclipse 中为 Java 枚举生成 switch 语句的模板或其他东西?
所以当我得到一个枚举并且我想要一个包含所有值的开关时,我不必自己写所有的东西?
至少在 3.5 中肯定有。
从这样的事情开始:
switch(a.getType()){ }
您需要做的就是单击 switch 关键字并按 CTRL+1。您应该得到一个下拉菜单,其中包括“添加缺少的案例陈述”选项
Eclipse 3.4 中的内容辅助将帮助您编写代码。只需键入case并按 Ctrl+Space,您将获得未使用的枚举列表。
case