If I have an enum object, is it considered a primitive or a reference?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a reference type. Java primitives are
boolean byte short char int long float double.You can get the enumeration constant’s value by calling
ordinal(), which is used by EnumSet and EnumMapiteratorand “traverses the elements in their natural order (the order in which the enum constants are declared)”You can even add your own members to the enum class, like this: