public enum Rank {
TEN("Ten",1),
NINE("Nine",2),
EIGHT("Eight",0),
SEVEN("Seven",0);
private final String name;
private final int point;
/*
* @param rank should be byte
*/
private Rank(String name,int point)
{
this.name=name;
this.point=point;
}
How to replace int to byte in point. One way i can think of is using TEN("Ten",Byte.parseByte("1"));
Is there any better or/and shorter approach?
Just cast
to a byte
, like so:
public enum Rank {
TEN("Ten", (byte)1),
NINE("Nine", (byte)2),
EIGHT("Eight", (byte)0),
SEVEN("Seven", (byte)0);
private final String name;
private final byte point;
private Rank(String name, byte point)
{
this.name = name;
this.point = point;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With