CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
CodeGym/Help with Java Tasks/I thought enum was also a java collection. This make it m...
null
Level 26
Orlando
  • 3/3/20
  • 1212views
  • 1comment

I thought enum was also a java collection. This make it more simple than using ArrayList tho.

Question about the task Month number
Java Syntax,  Level 8,  Lesson 11
Under discussion
The program reads the name of the month from the keyboard and then displays its number on the screen in a phrase like: "May is month 5".
Use collections.

Requirements:
  • The program should read one value from the keyboard.
  • The program should display text on the screen.
  • The program must use collections.
  • The program should read from the keyboard the name of the month and display its number on the screen according to the specified template.
....
package com.codegym.task.task08.task0828; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashSet; import java.util.HashMap; import java.util.List; import java.util.Set; /* Month number */ public class Solution { enum Month{ January, February, March, April, May, June, July, August, September, October, November, December } public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String monthName = reader.readLine(); Month month = Month.valueOf(monthName); System.out.println(monthName + " is month "+(month.ordinal() + 1)); } }
0
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Anonymous #10410173 Full Stack Developer
4 March 2020, 12:14
you should use collection
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym