Created
December 2, 2016 07:22
-
-
Save rhexgomez/fcf197719a55f3c541dc9ca98918aa84 to your computer and use it in GitHub Desktop.
Java Enum#values() nature.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EnumTest { | |
public static void main(String[] args) { | |
TestEnum[] values = TestEnum.values(); | |
TestEnum[] values2 = TestEnum.values(); | |
// Compare the array itself. | |
if (values == values2) { | |
System.out.println("Same"); | |
} else { | |
System.out.println("Nope"); //output | |
} | |
// Comparing the contents of the array. | |
if (values[0] == values2[0]) { | |
System.out.println("Same"); //output | |
} else { | |
System.out.println("Nope"); | |
} | |
} | |
enum TestEnum { | |
TEST_A | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment