Crell / enum-comparison

A comparison of enumerations and similar features in different languages
80 stars 7 forks source link

Java enums do support constructors with parameters #7

Closed jurchiks closed 4 years ago

jurchiks commented 4 years ago

This comparison survey states: Enums do not support constructors. (Or rather, the constructor is private, so you cannot pass parameters to it.)

Official documentation disagrees: https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html Scroll down to public enum Planet, there is a constructor with parameters, which, naturally, can be overloaded.

This is a huge oversight.

Crell commented 4 years ago

Hm. Looks like I misread the other tutorial I was reading.

I have corrected it. Thanks.

jurchiks commented 4 years ago

You missed the Summary table.