Java:Out with the Old,In with the New [英] Java: Out with the Old, In with the New

查看:107
本文介绍了Java:Out with the Old,In with the New的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java即将推出版本7.在我看来,必须有大量的教科书和培训手册,这些教科书和培训手册都是基于Java的旧版本教授方法,其中教授的方法现在有更好的解决方案。

Java is nearing version 7. It occurs to me that there must be plenty of textbooks and training manuals kicking around that teach methods based on older versions of Java, where the methods taught, would have far better solutions now.

有哪些样板代码情况,特别是那些你看到人们通过习惯实现的情况,你发现自己重构利用最新版本的Java?

What are some boilerplate code situations, especially ones that you see people implement through force of habit, that you find yourself refactoring to utilize the latest versions of Java?

推荐答案

枚举。替换

public static final int CLUBS = 0;
public static final int DIAMONDS = 1;
public static final int HEARTS = 2;
public static final int SPADES = 3;

with

public enum Suit { 
  CLUBS, 
  DIAMONDS, 
  HEARTS, 
  SPADES 
}

这篇关于Java:Out with the Old,In with the New的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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