CJCoding With Joseph
15per day

Enum Traffic Light with if

Use a Java enum and an if statement to determine and print the action for a traffic light.

Expected Output:
Go

The enum Light is already declared. Set the current light to Light.GREEN, then use if to check: print 'Go' if GREEN, otherwise print 'Stop'. With enums, always use == for comparison, not .equals().

Expected Output:

Go
Topics:
Miscellaneous
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.