I'm not sure this is the final statement, but it seems to me that the Java API prefers persistent ints over enums. Of the parts of the API that I used, I came across a lot of final static int constants, where you could use instead of enum . Someday such an example that I am looking at this moment:
From java.awt.BasicStroke :
public final static int CAP_BUTT = 0; public final static int CAP_ROUND = 1; public final static int CAP_SQUARE = 2;
Actually, I donβt think I have ever seen an enumeration used in the standard Java API class. Why is this?
I am developing an API for my own application (about a billion times smaller than the Java API, but I'm still trying to be smart) and trying to decide whether to use constant ints or enums. THIS publishes links to a very popular book that I have not read yet, which means that listings have many advantages. Most other high-level answers in the same topic agree. So why doesn't Java seem to use its own enumeration capabilities?
The111
source share