+ 1
What is enum? We can use final also. What is difference between enum and final?
3 odpowiedzi
+ 2
Final : a value is set final to make it a constant, that is it can never be changed.
Enum : We create a datatype just like int, float, etc., and also define, what values the user can enter.
Eg: final b=10;
Any action on b will never change its value
enum Month {Jan,May,Apr};
Month a;
a is a variable of datatype Month and can hold only the values specified. Either Jan or May or Apr
+ 1
Enums are special classes used to define constants and normally used for things like days of the week, planets , point of compass etc. And also enums are already final and static. For more information visit tutorialspoint or stack overflow
0
final gets one value and that can't be changed but we can declare final and set it's value later, like
final int a;
//code
a=7;
enums are all predefined and there is few of them, as Ousmane said.
if u have 1 or 2 variables use final in any case..