Java Enum toString() MethodThe toString() method of Enum class returns the name of this enum constant, as the declaration contains. The toString() method can be overridden, although it's not essential. SyntaxParametersNA Override:The toString() method of Enum class overrides the toString() method of Object class. Return ValueThe toString() method returns this enum constant's name. Example 1Output: Seven Planets : 1 Mercury 2 Venus 3 Earth 4 Mars 5 Jupiter 6 Uranus 7 Neptune Example 2Output: Enter your positon: Second Congratulation! You have won a Silver medal. Example 3Output: Enter your grade C Good You scored above 70 Next TopicJava-enum-valueof-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India