All Questions
13 questions
0
votes
2
answers
402
views
Kotlin Generics - It is possible get integer position of an element of whatever type passed like ordinals method does for Enum defined classes?
There's an already built in way that fulfill my request?
I know Set are unordered
I need to do a vector based Set.
I need to know the position of any value of a generic type to place them in the ...
1
vote
2
answers
193
views
Is there any significant reason to use the ordinal of an enum in a switch case, instead of using the enum?
I recently came across the following example:
CommandKey key = command.getKey();
switch(key.ordinal()) {
case 1:
return IncidentType.StatusChange;
case 2:
return ...
2
votes
3
answers
7k
views
Setting Ordinal Enum values to start from 1 instead of 0
I have a Enum with three values. It's being used as a property in an Entity bean.
Here's the property in the bean:
@Enumerated(EnumType.ORDINAL)
private BillingMethod billingMethod;
Here's the enum ...
0
votes
3
answers
2k
views
Maximum value in array containing Objects Java
I have an array named trick of type Card which stores the Suit and the Rank.
Is there a way to use Collections.max to find the highest ranked card? I have used ordinals in other aspects of my code but ...
72
votes
3
answers
74k
views
Do C++ enums Start at 0?
If I have an enum that does not assign numbers to the enumerations, will its ordinal value be 0? For example:
enum enumeration { ZERO,
ONE,
TWO,
...
0
votes
0
answers
520
views
Wrong column type Hibernate
I have an enum and want to store it as integer in the database. I put the annotation @Enumerated(value=EnumType.ORDINAL) at my attribute and start my application with hibernate.validate. It then says ...
4
votes
2
answers
523
views
Java enum ordinal returning -1?
Alright so I'm currently writing some code for a project I'm working on, and I decided an Enum for data storage will be my best bet. But in the first time in my life, the enum.ordinal() returns -1?
...
1
vote
5
answers
897
views
How to cast an enum ordinal as a String?
I need to pass the ordinal value of an enum as a parameter to a HashMap<String, String>. In other words, I want to cast an ordinal as a String.
Right now, I'm doing this:
HashMap<String, ...
5
votes
3
answers
5k
views
use of ordinal inside Java Enum definition
I notice that the Java Enum Documentation states the ordinal method:
Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned ...
0
votes
1
answer
470
views
Enums Ordinal in Obj-C (using enums for Z Values in Cocos2D)
I want to avoid manually assigning random Z values for Layers/Nodes in Cocos2D and planning on using enums for it.
I know enums are ordinal-ordered but is it safe to rely on the enum ordering in Obj-...
0
votes
5
answers
2k
views
How do I select a specific enum.ordinal() using another enum?
First, my code (It is far from perfect, I don't really know what I am doing) is this:
public enum Chord { MAJOR, MINOR, DIMINISHED, BASS, BASS2 }
public enum Scales { C, D, E, F, G, A }
public ...
3
votes
4
answers
4k
views
Creating console command list - how to do it right with Java
For a homework I code in Java(with which I'm a newbie), I bump into the problem of creating a console command list. The user will be confronted with a set of commands, among which s/he will choose his/...
394
votes
17
answers
360k
views
Cast Int to enum in Java
What is the correct way to cast an Int to an enum in Java given the following enum?
public enum MyEnum
{
EnumValue1,
EnumValue2
}
MyEnum enumValue = (MyEnum) x; //Doesn't work???