The Java Language Features that Nobody Uses
Join the DZone community and get the full member experience.Join For Free
I read Anthony Goubard’s “Top 10 Unused Java Features” on JavaLobby earlier today. I agree with some of his selections but I think he missed out a few key features that nobody uses. Restricting myself to just language features (the API is too huge), here are four more widely unused features of Java.
4. The short data type
You use it? I don’t believe you. Everybody* uses int when they want integers, even if they don’t need a 32-bit range.
3. Octal Literals
Who uses Octal these days?** Hexadecimal is a more useful shorthand for binary values. Worse, the leading-zero notation for Octal literals is just confusing:
int a = 60;
int b = 060;
System.out.println(a + b); // Prints 108.
2. Local Classes
Java has four types of nested class, three of which are widely used. As well as static nested classes, named inner classes and anonymous inner classes, you can also define named classes within methods, though it’s rare to see one in the wild.
public class TopLevelClass
public void someMethod()
// Some fields and methods here.
LocalClass forLocalPeople = new LocalClass();
1. Strict FP
There is probably a programmer out there somewhere for whom Java’s strictfp is vital, but I haven’t met him or her. If you already know what strictfp is used for then you are probably in the top 5% of Java programmers. If you don’t know what strictfp does, here you go, welcome to the top 5%. It’s basically about making sure that your calculations are equally wrong on all platforms.
* OK, maybe you used to be a C programmer.
** Here’s your rhetorical answer.
Opinions expressed by DZone contributors are their own.