Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • what is Enum in your example? Commented Dec 16, 2018 at 17:27
  • I want to make it universal, so I put just Enum as type of argument to match any Enum object to this method. Commented Dec 16, 2018 at 17:28
  • And values does only work for the enum type, e.g. MyEnum.values() but clearly not for a specific value of an enum like in your method... Commented Dec 16, 2018 at 17:29
  • ok, that can't work for any enum as explained by the others in the comment Commented Dec 16, 2018 at 17:29
  • Reflection would also be a workaround, but who wants to use reflection...getDeclaredField("$VALUES"); or Enum.class.getDeclaredMethod("values"); for the enum class Commented Dec 16, 2018 at 17:31