What type of variable declaration is this in java

class FreshJuice {
   enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }
   FreshJuiceSize size;
}

What type of variable size?

Is FreshJuiceSize size;shorhand way of declaring sizeas an instance variable?

+4
source share
5 answers

In your example, sizeis a member variable with type FreshJuiceSize(a enumlimited to 3 values ​​you specify).

, - : public, protected private. "package-private", , , . Java .

+3

. enum FreshJuiceSize.

0

FreshJuiceSize; shorhand ?

FreshJuiceSize, . " " " ".

0

The size of a variable of type FreshJuiceSize FreshJuiceSize is an enumeration, so the size takes only one of {SMALL, MEDIUM, LARGE} set

0
source

FeshJuice is a class - most likely, private - not the main one - judging by the absence of the declaration public class classname - FreshJuiceSize is the name of the enumeration (similar to the name of the array) and the size of FreshJuiceSize; declares a variable size member (I forget the term) FreshJuiceSize

0
source

Source: https://habr.com/ru/post/1667610/


All Articles