enum tag

6 questions


1 answers
150 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?

2 years ago

1 answers
140 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...

2 years ago

1 answers
138 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...

2 years ago

1 answers
142 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?

2 years ago

1 answers
114 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...

2 years ago

1 answers
69 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...

2 years ago

© 2024 OneMinuteCode. All rights reserved.