number « enum « Java Data Type Q&A

1. Java Enums - Number add() and classification method

I am creating an api for a phonebook which has 3 different types of phone-numbers:FAX, HOME, WORK, CELL I want to add a number to a specific type but do not want ...

2. Switch statement: number to enum value / 1002 = MyEnum.NewYorkID

Well, I want to make this work

public static void main(String[] args) {

    int cityId = 1234;

    switch (cityId) {

3. Java enum search by number range

Is it possible to do enum like below

enum {

 10  poor
 100  rich
 1000 very_rich

so that when i do search by input value let say 101. it will return ...

4. Java "enum" : can you use non-consecutive ordinal numbers ?

Hi, When using java "enum" , can I ask java to assign my own specific ordinals, instead of the default consecuitive values ? For example, say I have the following ACTION codes (I can't control the code values because they're taken from some legacy system): * DELETE = 2; * ADD = 5; * EDIT =7; I couldn't find any 'enum' ...

5. Enums with numbers

6. getting position number from enum class

7. Get an enum based on a number