hashCode(): This method is available in java.lang.Enum class of Java.
Syntax:
int java.lang.Enum.hashCode()
This method returns a hash code for this enum constant.
Parameters: NA
Returns: a hash code for this enum constant.
Exceptions: NA
Approach
Java
enum Colour {RED, GREEN, GRAY, ORANGE}public class EnumhashCode {public static void main(String[] args) {System.out.println(Colour.RED.hashCode());}}
Output:
405662939
No comments:
Post a Comment