Practice using enumeration to display traffic light colors

The code is as follows:

//Practice using enumeration to display traffic light colors class demo11 {public static void main (string [] args) {trafficlight light light = trafficlight.yellow; system.out.println (light); switch (light) {Case Red: system.out.println ("red light, stop"); break; Case Green: system.out.println ("green light, line"); break; case yellow: system.out.println ("yellow light, stop"); break;}}} enum TrafficLight{ Red,Green,Yellow }

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>