enum tag

6 questions


1 answers
135 views
0
Is it possible to cast int as enum in Java?

public enum MyEnum{ EnumValue1, EnumValue2}MyEnum enumValue = (MyEnum) x; //Doesn't work???How can I cast int as enum?

1 years ago

1 answers
125 views
0
I'm asking about the definition of enum type

enum {RANDOM, IMMEDIATE, SEARCH} strategy;strategy = IMMEDIATE;You can use it like this on C++, but there's an error on CIt's too hard.What should I do?error: conflicting types for ‘strategy’error: pr...

1 years ago

1 answers
127 views
0
The error "You tried to define an enum named "stage" on the model "Challenge", but..." occurs when rails define an enum in the model.

You want to define the following enum in the model:class Model < ActiveRecord::Base enum stage: {member_only: 0, public: 1, demo: 2}The following error occurs:You tried to define an enum named stag...

1 years ago

1 answers
124 views
0
Is it possible to do the epilogue of enum?

As far as I know, ++ or += cannot be used in enumThen, how do I translate C++ enum from beginning to end?

1 years ago

1 answers
104 views
0
When comparing enum members, == and equals()

public useEnums(SomeEnum a) { if(a.equals(SomeEnum.SOME_ENUM_VALUE)) { ... } ... }When I tried to compare the two members of enum in Java like above, I wrote .equals()Looking at it public useEnum...

1 years ago

1 answers
64 views
0
To change the enum value to int

public enum TAX { NOTAX(0),SALESTAX(10),IMPORTEDTAX(5); private int value; private TAX(int value){ this.value = value; }}TAX var = TAX.NOTAX;public int getTaxValue(){ // What am I supposed to do here...

1 years ago

© 2024 OneMinuteCode. All rights reserved.