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));
}
}
I thought enum was also a java collection. This make it more simple than using ArrayList tho.
Under discussion
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