A checklist for tasks that could be performed on an existing Java 2 sourcecode when migrating to Java 5+:
- use Generics always and everywhere
- use autoboxing (remove all “new Integer” etc)
- replace overloaded methods with var-args
- use Enums instead of integer constants
Replace class… | …with class… | …because… |
---|---|---|
StringBuffer | StringBuilder | better performance (not threadsafe) |
BufferedWriter, FileWriter | PrintWriter | enhanced formatting |
StringTokenizer | Scanner | includes parsing |
Iterator | Iterable | (for APIs) enhanced “for” loop can be used |