{"id":91500,"date":"2023-08-10T16:49:38","date_gmt":"2023-08-10T11:19:38","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/"},"modified":"2024-09-03T14:22:45","modified_gmt":"2024-09-03T08:52:45","slug":"java-enums","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/","title":{"rendered":"Java Enum With Values"},"content":{"rendered":"\n<p>In the dynamic world of software engineering, programming languages and their constructs form the crux of efficient and robust systems. Java, a language known for its 'write once, run anywhere' principle, holds a distinctive position in this landscape. Java is a cornerstone in numerous modern software development projects as it is object-oriented, platform-independent, and encompasses various features like encapsulation, polymorphism, inheritance, and abstraction.<\/p>\n\n\n\n<p>One unique feature that truly stands out in Java is the concept of Enumerations or 'Enum'. Enum is a special data type for enabling a variable to be a set of predefined constants. This feature significantly enhances the flexibility and readability of the code, making it easier to maintain and less prone to errors.<\/p>\n\n\n\n<p>As we delve deeper into the topic, we will shed light on the specifics of Java enums, particularly focusing on enums with values. Let's embark on this exciting journey into the realm of Java enum and see how it plays a crucial role in the broader field of software engineering.<\/p>\n\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy Pro<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-title-link\">Java Programming Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Learn Java the right way! Our course teaches you essential programming skills, from coding basics to complex projects, setting you up for success in the tech industry.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>16.05 Hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>3 Projects<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/master-java-programming\" class=\"courses-cta-button\">\n                Learn Java Programming\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"delving-deeper-into-java-enum\"><strong>Delving Deeper into Java Enum<\/strong><\/h2>\n\n\n\n<p>Java Enum, short for Java Enumerations, is a special data type that enables a variable to have one of many predefined constants. These constants are final, implying their values cannot be changed after their declaration. Enums are primarily used when you want to represent a fixed set of constants in your program. For instance, the days of a week, directions (north, south, east, west), or the state of a game (playing, paused, stopped) can be aptly represented using enums.<\/p>\n\n\n\n<p>But why use Java enum? The most striking advantage of an enum is that it helps create cleaner and more intuitive code. Instead of using integers or strings to represent a fixed set of values that can lead to errors and confusion, an enum provides a specific type with predefined constants. This approach makes your code much more readable and maintainable.<\/p>\n\n\n\n<p>To illustrate this, let's take a simple example. Suppose you want to represent the seven days of the week. Instead of using integers from 1 to 7 or strings (\"Sunday\u201d, \u201cMonday\", etc.), you can create an enum like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public enum Day {\n\n&nbsp;&nbsp;&nbsp;&nbsp;SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;\n\n}<\/pre>\n\n\n\n<p>This way, you can use the \u2018Day\u2019 enum whenever you are dealing with a day in your code. It will make your code cleaner, more readable, and less error-prone, as you won't be able to assign any value to a day outside the defined enum constants.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"java-enum-with-values\"><strong>Java Enum with Values<\/strong><\/h2>\n\n\n\n<p>While Java enum with predefined constants offers simplicity and readability, there are instances where we may need additional information with each constant, and here is where Java enum with values comes in.<\/p>\n\n\n\n<p>Let's modify the 'Day' enum we used earlier and add a feature that assigns a type to each day \u2014 weekdays or weekends. This new feature can be implemented using Java enum with values. Here's how you can do it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public enum Day {\n\n&nbsp;&nbsp;&nbsp;&nbsp;SUNDAY(\"Weekend\");\n\n&nbsp;&nbsp;&nbsp;&nbsp;MONDAY(\"Weekday\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;TUESDAY(\"Weekday\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;WEDNESDAY(\"Weekday\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;THURSDAY(\"Weekday\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;FRIDAY(\"Weekday\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;SATURDAY(\"Weekend\"),\n\n&nbsp;&nbsp;&nbsp;&nbsp;private String type;\n\n&nbsp;&nbsp;&nbsp;&nbsp;Day(String type) {\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.type = type;\n\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;public String getType() {\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return type;\n\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n}<\/pre>\n\n\n\n<p>In the above code, we have extended the 'Day' enum to include a type for each day. Each constant in the enum now has an associated value. We achieve this by defining a private variable 'type' and a constructor that takes a string as an argument. Finally, we add a getter method <strong><em>getType()<\/em><\/strong>, to fetch the type of any day.<\/p>\n\n\n\n<p>Now, you can fetch the type of day using the following code:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Day dayType = Day.SUNDAY;\n\nSystem.out.println(dayType.getType());&nbsp; \/\/ This will print \"Weekend\"<\/pre>\n\n\n\n<p>Java enum with values adds another layer of versatility to our code. It allows us to assign relevant information to our constants, making our code more meaningful and rich in context.<\/p>\n\n\n\n<p>Implementing such advanced Java features can be challenging but equally rewarding. If you're new to Java or need to brush up your skills, consider enrolling in a <a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-programming\">free Java course<\/a>. A well-structured course can help you understand these concepts in-depth, along with practical examples.<\/p>\n\n\n\n<p><strong>Check out free courses on Java by <a href=\"https:\/\/www.mygreatlearning.com\/academy\" target=\"_blank\" rel=\"noreferrer noopener\">Great Learning Academy<\/a> below:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/java-projects\" target=\"_blank\" rel=\"noreferrer noopener\">Java Projects<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/data-structures-and-algorithms-in-java\" target=\"_blank\" rel=\"noreferrer noopener\">Java Algorithms<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/javascript-projects\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript Projects<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"java-enum-methods-and-implementation\"><strong>Java Enum Methods and Implementation<\/strong><\/h2>\n\n\n\n<p>Now that we have explored Java Enum with values, let's look at the built-in methods offered by Java Enum and how we can use them.<\/p>\n\n\n\n<p>Java Enum comes equipped with several useful methods like <strong><em>values()<\/em><\/strong>, <strong><em>valueOf()<\/em><\/strong>, <strong><em>name()<\/em><\/strong>, and <strong><em>ordinal()<\/em><\/strong>, among others. These methods provide functionalities that make working with enums easier and more efficient.<\/p>\n\n\n\n<p>The <strong><em>values()<\/em><\/strong> method is a static method that returns an array containing all the enum constants in the order they were declared. For instance, <strong><em>Day.values()<\/em><\/strong> would return an array of all seven days of the week.<\/p>\n\n\n\n<p>The <strong><em>valueOf()<\/em><\/strong> method is also a static method that takes a string as an argument and returns the enum constant with the corresponding name. For example, <strong><em>Day.valueOf(\"SUNDAY\")<\/em><\/strong> would return the enum constant <strong><em>SUNDAY<\/em><\/strong>.<\/p>\n\n\n\n<p>The <strong><em>name()<\/em><\/strong> method returns the name of the enum constant, exactly as declared in its enum declaration.<\/p>\n\n\n\n<p>The <strong><em>ordinal()<\/em><\/strong> method returns the position of the enum constant in the Enum declaration. For example, in our \u2018Day\u2019 enum, <strong><em>SUNDAY<\/em><\/strong> would have an ordinal value of 0, <strong><em>MONDAY<\/em><\/strong> would be 1, and so forth.<\/p>\n\n\n\n<p>Here's an example demonstrating these methods:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public class Main {\n\n&nbsp;&nbsp;&nbsp;&nbsp;public static void main(String[] args) {\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for (Day dayType : Day.values()) {\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(dayType.name() + \": \" + dayType.ordinal() + \", Type: \" + dayType.getType());\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n}\n\nThe above code prints:\n\nSUNDAY: 0, Type: Weekend\n\nMONDAY: 1, Type: Weekday\n\nTUESDAY: 2, Type: Weekday\n\nWEDNESDAY: 3, Type: Weekday\n\nTHURSDAY: 4, Type: Weekday\n\nFRIDAY: 5, Type: Weekday\n\nSATURDAY: 6, Type: Weekend<\/pre>\n\n\n\n<p>As you can see, these built-in methods of Java Enum add versatility and efficiency to our code. They also make our code cleaner and easier to understand.<\/p>\n\n\n\n<p>Mastering these methods and their effective implementation is crucial for any aspiring Java developer. Consider enrolling in a <a href=\"https:\/\/www.mygreatlearning.com\/software-engineering\/courses\">software engineering course<\/a> focusing on Java and its core concepts to enhance your learning curve. It will help you understand Java enum's nuances and provide a strong foundation for your journey in software engineering.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"benefits-of-using-enum-in-java\"><strong>Benefits of Using Enum in Java<\/strong><\/h2>\n\n\n\n<p>Java enum is a powerful feature that offers several benefits, making it an essential tool for Java developers. Let's delve into the key advantages of using enum in Java:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Type Safety: <\/strong>Enum ensures type safety by restricting a variable to have one among a predefined set of constants, which limits the possibility of invalid inputs, leading to less error-prone code.<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Readability and Maintainability: <\/strong>Enum constants are named in a way that gives them meaningful context that increases code readability, making it easier to understand for others working on the same codebase. The ease of understanding directly impacts the maintainability of the code, contributing to a smoother software development process.<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Added Functionality: <\/strong>Java enum has powerful features, unlike traditional languages where enumerations are just named integers. Enums in Java are objects, meaning they can have <a href=\"https:\/\/www.mygreatlearning.com\/blog\/constructor-in-java\/\">constructors<\/a> and methods and even implement <a href=\"https:\/\/www.mygreatlearning.com\/blog\/interface-in-java\/\">interfaces<\/a>, which opens a whole new world of possibilities, making Java Enum versatile and dynamic.<\/li>\n<\/ol>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Singleton Capability: <\/strong>Enum can effectively implement the singleton design pattern, which restricts a class to having only one instance. Enum singletons are thread-safe and provide an easy and efficient way to create singletons.<\/li>\n<\/ol>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li><strong>Use in Java Collections: <\/strong>Enum sets and maps are highly efficient and provide powerful capabilities like maintaining a particular order or automatically associating values with keys.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"wrapping-up\"><strong>Wrapping up<\/strong><\/h2>\n\n\n\n<p>Throughout this blog, we embarked on an enlightening journey exploring Java enum, its distinctive features, and the benefits it brings to your programming toolkit. Enum in Java is an impressive construct that elevates your code's robustness, readability, and overall quality. Particularly, Java enum with values extends the conventional enum, making your code more dynamic and context-rich.<\/p>\n\n\n\n<p>Moreover, the built-in methods provided by enum in Java, such as <strong><em>values()<\/em><\/strong>, <strong><em>valueOf()<\/em><\/strong>, <strong><em>name()<\/em><\/strong>, and <strong><em>ordinal()<\/em><\/strong>, further increase the utility and effectiveness of enum. Combined with the type of safety the enum ensures, these features make it an indispensable part of the Java programming language.<\/p>\n\n\n\n<p>Remember, the journey of mastering any programming language, especially one as comprehensive as Java, is a marathon, not a sprint. So, keep learning, keep exploring, and most importantly, keep coding! Enjoy the journey, and the destination will come to you. Happy coding!<br><br>Explore the <a href=\"https:\/\/www.mygreatlearning.com\/academy-iitroorkee-full-stack\" target=\"_blank\" rel=\"noreferrer noopener\">Advanced Certificate Program in Full Stack Software Development<\/a> if you have a keen interest in establishing a career within this field.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the dynamic world of software engineering, programming languages and their constructs form the crux of efficient and robust systems. Java, a language known for its 'write once, run anywhere' principle, holds a distinctive position in this landscape. Java is a cornerstone in numerous modern software development projects as it is object-oriented, platform-independent, and encompasses [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":91502,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[36826],"content_type":[36252],"class_list":["post-91500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-java","content_type-tutorials"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Enum With Values<\/title>\n<meta name=\"description\" content=\"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Enum With Values\" \/>\n<meta property=\"og:description\" content=\"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-10T11:19:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-03T08:52:45+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"683\" \/>\n\t<meta property=\"og:image:height\" content=\"512\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Java Enum With Values\",\"datePublished\":\"2023-08-10T11:19:38+00:00\",\"dateModified\":\"2024-09-03T08:52:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/\"},\"wordCount\":1307,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/iStock-454346967.jpg\",\"keywords\":[\"java\"],\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/\",\"name\":\"Java Enum With Values\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/iStock-454346967.jpg\",\"datePublished\":\"2023-08-10T11:19:38+00:00\",\"dateModified\":\"2024-09-03T08:52:45+00:00\",\"description\":\"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/iStock-454346967.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/iStock-454346967.jpg\",\"width\":683,\"height\":512},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/java-enums\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Enum With Values\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java Enum With Values","description":"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/","og_locale":"en_US","og_type":"article","og_title":"Java Enum With Values","og_description":"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2023-08-10T11:19:38+00:00","article_modified_time":"2024-09-03T08:52:45+00:00","og_image":[{"width":683,"height":512,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Java Enum With Values","datePublished":"2023-08-10T11:19:38+00:00","dateModified":"2024-09-03T08:52:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/"},"wordCount":1307,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg","keywords":["java"],"articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/","url":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/","name":"Java Enum With Values","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg","datePublished":"2023-08-10T11:19:38+00:00","dateModified":"2024-09-03T08:52:45+00:00","description":"Discover the power of Java enums with values in this comprehensive guide brought to you by Great Learning.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/java-enums\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg","width":683,"height":512},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/java-enums\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Java Enum With Values"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg",683,512,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967-300x225.jpg",300,225,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg",683,512,false],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg",683,512,false],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg",683,512,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967.jpg",683,512,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967-640x512.jpg",640,512,true],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967-96x96.jpg",96,96,true],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2023\/07\/iStock-454346967-150x112.jpg",150,112,true]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"In the dynamic world of software engineering, programming languages and their constructs form the crux of efficient and robust systems. Java, a language known for its 'write once, run anywhere' principle, holds a distinctive position in this landscape. Java is a cornerstone in numerous modern software development projects as it is object-oriented, platform-independent, and encompasses&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/91500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=91500"}],"version-history":[{"count":9,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/91500\/revisions"}],"predecessor-version":[{"id":104505,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/91500\/revisions\/104505"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/91502"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=91500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=91500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=91500"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=91500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}