Skip to content

Instantly share code, notes, and snippets.

@rhexgomez
Created December 2, 2016 07:22
Show Gist options
  • Save rhexgomez/fcf197719a55f3c541dc9ca98918aa84 to your computer and use it in GitHub Desktop.
Save rhexgomez/fcf197719a55f3c541dc9ca98918aa84 to your computer and use it in GitHub Desktop.
Java Enum#values() nature.
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