(转)Coding小技巧-在Eclipse里简化静态引入

 

在eclipse里,有个黄金快捷键组合 ctrl + shift + O,大家应该不陌生吧!
当你敲完类名后触发它,它会帮你自动完成import,很实用的一个快捷键。

在JDK1.5发布后,java里引入了一个新的语法,static import。
该语法的本意是,简化静态属性在调用时的代码量,提高可读性。

但在eclipse里,如果你不提供类名,直接敲你想要的静态成员名或方法名,eclipse是无从查找的。
于是有些人,可能就使用人肉输入 import static xxx。(我就是其中之一)

其实,为了解决这个问题,eclipse早就引入了静态类预设功能。该功能的入口是
Windows -> Preferences -> Java -> Editor -> Content Assist -> Favorites
只要设置包含静态成员或方法的类,在编码过程中,你就可以直接敲名字了(或使用 alt + / 补全)。

 

原文:http://kenwublog.com/simplify-static-import-in-eclipse

 

 

Static Import *

Static import support is still kind of clunky in Eclipse, e.g. copy/pasting code that uses static imports from one class to another will not bring the static imports with it, creating compile errors that are annoying to resolve.

Setting Java > Code Style > Organize Imports > Number of static imports needed for * to 1means that MigrationKeywords.* will be used as soon as you have a single static import keyword in use and makes the copy/paste experience nicer.

 

原文:http://joist.ws/eclipseTips.html

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值