Eclipse Java:“创建字段”的模板快速修复建议? [英] Eclipse Java: Template for the 'create field' quick fix suggestion?

查看:174
本文介绍了Eclipse Java:“创建字段”的模板快速修复建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在构造函数中,我经常分配给一个不存在的字段,并在'CurrentType'类型中选择Ctrl + 1Create field'memberField'。

In constructors I very often assign to a non-existing field and choose Ctrl+1 "Create field 'memberField' in type 'CurrentType'".

是我希望该字段默认是最终的,哪个不是。有没有一个模板这个快速修复某处?谢谢。

The problem is that I want the field to be final by default, which it isn't. Is there a template for this quick fix somewhere? Thanks.

推荐答案

我没有看到任何明显的方法,通过代码模板,也许因为这不是Java语言默认值。

虽然有博客帖子 在那里倡导数据不变性默认情况下,这不是使用的默认风格,因为已经(或许多其他SO问题

I didn't see any obvious way to do that through code template, perhaps because this is not the Java language default.
While there are blog posts out there advocating for Data immutability by default, this is not the default style in use, as in has been previously debated in SO (or in many other SO questions)

但是,您可以修改清理过程(如果需要,每次保存时都会发生):

However, you can modify the Cleanup process (occurring on each save if you want):

Java > Code Style > CleanUp > Code Style

选择使用修饰符'final' / code>

这篇关于Eclipse Java:“创建字段”的模板快速修复建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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