Enumerations are a specification that specifies the form of arguments so that type mismatches (compile-time checking) are eliminated and the ambiguity that can arise from ints is explicitly replaced.

####Android does not recommend using enum types.

Check out the official documentation:

Android Developer-Avoid enumerations

Avoid enumerations A single enum can add about 1.0 to 1.4 KB of size to your app’s classes.dex file quickly accumulate for complex systems or shared libraries. If possible, consider using the @IntDef annotation and ProGuardto strip enumerations out and convert them to integers. This type conversion preserves all of the type safety benefits of enums.

Each enumeration constant increases the size of your application’s classes.dex file by approximately 1.0 to 1.4 KB. This additional footprint can quickly add up in your system or shared libraries. Android recommends using the @intdef annotation or ProGuard instead if possible.

#### This is explained in detail in the Android Performance Example (3) : Suppose we have a code with a compiled dex size of 2556 bytes. On this basis, add some code that uses ordinary static constant correlation as the judge value:

After adding the above code, the compiled dex size is 2680 bytes, an increase of 124 bytes from 2556 bytes. If enum is used, the situation is as follows:

The dex size with enum is 4188 bytes, which is an increase of 1632 bytes compared with 2556. The increase is 13 times that with static int. Not only that, use enum, run timeIt also incurs additional memory footprint, as shown in the figure below:

Therefore, It is strongly recommended not to use enum in Android applications.

Android recommends using @intdef instead of enumerations. Tomorrow we’ll look at the @intdef annotation 🙂