gpt4 book ai didi

java - 类中声明的枚举类型是隐式静态的吗?

转载 作者:太空狗 更新时间:2023-10-29 22:46:11 26 4
gpt4 key购买 nike

<分区>

class Coffee{   
enum CoffeeSize{BIG,HUGE,OVERWHELMING}
CoffeeSize size;
}

class CoffeeTest{
public static void main(String[] args)
{
Coffee drink=new Coffee();
drink.size=Coffee.CoffeeSize.BIG;
}
}

Coffee.CoffeeSize.BIG:我只需使用类名 Coffee 即可获得 CoffeeSize。当我认为枚举类型是隐式静态时,我是否正确?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com