设置Eclipse: 开启assertion/设置tab缩进为空格

这篇文章引自MIT公开课 6.005 — Software Construction on MIT OpenCourseWare, 链接为 https://ocw.mit.edu/ans7870/6/6.005/s16/getting-started/

1 Open Eclipse preferences.

  • Windows & Linux : go to Window → Preferences .
  • OS X : go to Eclipse → Preferences .

2 Make sure Eclipse is configured to use Java 8

  • In preferences, go to Java → Installed JREs . Ensure that “Java SE 8” or “1.8.0_71” is the only one checked. If it’s not listed, click Search.
  • Go to Java → Compiler and set “Compiler compliance level” to 1.8. Click OK and Yes on any prompts.

3 Make sure assertions are always on .

Assertions are a great tool for keeping your code safe from bugs, but Java has them off by default.

  • In preferences, go to Java → Installed JREs . Click “Java SE 8”, click “Edit…”, and in the “Default VM arguments” box enter: -ea (which stands for enable assertions ).

4 Tab policy .

Configure your editor to use spaces instead of tabs, so your code looks the same in all editors regardless of how that editor displays tab characters.

  • In preferences, go to Java → Code Style → Formatter . Click the “Edit…” button next to the active profile.
  • In the new window, change the Tab policy to “Spaces only.” Keep the Indentation size and Tab size at 4. To save your changes, enter a new “Profile name” at the top of the window and click OK.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值