开发者

Make classes final by default in Eclipse?

开发者 https://www.devze.com 2023-03-13 17:49 出处:网络
Is there a way to make classes final by default in Eclip开发者_JAVA技巧se? i.e: on save actions, or in the create new class dialog?This truly is a hack, but what you can do in your eclipse settings is

Is there a way to make classes final by default in Eclip开发者_JAVA技巧se? i.e: on save actions, or in the create new class dialog?


This truly is a hack, but what you can do in your eclipse settings is set the following code template:

Make classes final by default in Eclipse?

Under Java > Code Style > Code Templates > Code > New Java Files, you can add the final keyword right before ${type_declaration}.

The caveat is that the final checkbox is no longer properly functional, but if you are someone that blows through the New Class dialog before clicking a box in the first place, then it may be a lesser evil to remove final in the actual code afterwards in the 10% of cases you need it.

The other caveat is that the first line of the class will look like final public MyClass; while still valid, it is not the more idiomatic public final MyClass.


Click on final check box in new class dialog.

Make classes final by default in Eclipse?

Also take a look at this: How to create a custom 'new class wizard' for Eclipse?

0

精彩评论

暂无评论...
验证码 换一张
取 消