Question: How can I gen an actual value from this enum with switch statement?

```
public enum Gender {
    Unknown(0),
    Male(1),
    Female(2);

    private static final SparseArray<Gender> lookupTable = new SparseArray<Gender>();
    static {
        for (final Gender gender : EnumSet.allOf(Gender.class)) {
            lookupTable.put(gender.intValue, gender);
        }
    }

    private final int intValue;

    public static Gender getByIntValue(int val) {
        return lookupTable.get(val);
    }

    private Gender(int intValue) {
        this.intValue = intValue;
    }

    public int getIntValue() {
        return intValue;
    }
}

```

Answer: 
It is not entirely clear hat you mean with '*actual value from this enum with switch statement*'. So here are the things to do with this enum:

You can use the enum in a `switch`-statement as follows:

```
Gender g = ...
switch(g) {
   case Male:
     // Do something for the males
     break;
   case Female:
     // Do something for the females
     break;
   case Unknown:
     // Argh... What to do?!
     break;
}

```

If you want to grab`intValue` of g, you can use:

```
int value = g.getIntValue();

```

If you want to grab a `Gender` value from an `int` you can use:

```
Gender g = Gender.getByIntValue(1);

```

If you want to grab a `Gender` value from a `String` you can use:

```
Gender g = Enum.valueOf(Gender, "Male");

```
Is that what you want ?

```
switch (genderVar) {
 case Unknown:
 case Male:
 case Female:
 default:
}

```