{"id":20639608,"url":"https://github.com/sanchezih/enums-java","last_synced_at":"2025-04-15T22:54:21.544Z","repository":{"id":247647192,"uuid":"826442042","full_name":"sanchezih/enums-java","owner":"sanchezih","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-01T03:35:09.000Z","size":12,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T22:54:17.357Z","etag":null,"topics":["enums","java-21"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sanchezih.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-09T18:03:20.000Z","updated_at":"2024-08-13T23:01:07.000Z","dependencies_parsed_at":"2024-07-14T09:47:36.505Z","dependency_job_id":"973de12c-cca4-413b-9c01-91e991129214","html_url":"https://github.com/sanchezih/enums-java","commit_stats":null,"previous_names":["sanchezih/enums-java"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanchezih%2Fenums-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanchezih%2Fenums-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanchezih%2Fenums-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanchezih%2Fenums-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanchezih","download_url":"https://codeload.github.com/sanchezih/enums-java/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249167439,"owners_count":21223505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["enums","java-21"],"created_at":"2024-11-16T15:25:17.844Z","updated_at":"2025-04-15T22:54:21.522Z","avatar_url":"https://github.com/sanchezih.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enum Types\n\n![GitHub last commit](https://img.shields.io/github/last-commit/sanchezih/enums-java)\n![GitHub repo size](https://img.shields.io/github/repo-size/sanchezih/enums-java)\n\nAn  _enum type_  is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.\n\nBecause they are constants, the names of an enum type's fields are in uppercase letters.\n\nIn the Java programming language, you define an enum type by using the  `enum`  keyword. For example, you would specify a days-of-the-week enum type as:\n\n```java\npublic enum Day {\n    SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY \n}\n```\n\nYou should use enum types any time you need to represent a fixed set of constants. That includes natural enum types such as the planets in our solar system and data sets where you know all possible values at compile time—for example, the choices on a menu, command line flags, and so on.\n\nJava programming language enum types are much more powerful than their counterparts in other languages. The  `enum`  declaration defines a  _class_  (called an  _enum type_). The enum class body can include methods and other fields. The compiler automatically adds some special methods when it creates an enum. For example, they have a static  `values`  method that returns an array containing all of the values of the enum in the order they are declared. This method is commonly used in combination with the for-each construct to iterate over the values of an enum type. For example, this code from the  `Planet`  class example below iterates over all the planets in the solar system.\n\n```java\nfor (Planet p : Planet.values()) {\n    System.out.printf(\"Your weight on %s is %f%n\",\n                      p, p.surfaceWeight(mass));\n}\n```\n\nIn the following example, `Planet` is an enum type that represents the planets in the solar system. They are defined with constant mass and radius properties.\n\nEach enum constant is declared with values for the mass and radius parameters. These values are passed to the constructor when the constant is created. Java requires that the constants be defined first, prior to any fields or methods. Also, when there are fields and methods, the list of enum constants must end with a semicolon.\n\n**Note:** The constructor for an enum type must be package-private or private access. It automatically creates the constants that are defined at the beginning of the enum body. You cannot invoke an enum constructor yourself.\n\nIn addition to its properties and constructor, `Planet` has methods that allow you to retrieve the surface gravity and weight of an object on each planet.\n\nBased on: https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanchezih%2Fenums-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanchezih%2Fenums-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanchezih%2Fenums-java/lists"}