Skip to content

Instantly share code, notes, and snippets.

@neojou
Created July 26, 2015 12:37
Show Gist options
  • Save neojou/6c4a726bd16af4ff145f to your computer and use it in GitHub Desktop.
Save neojou/6c4a726bd16af4ff145f to your computer and use it in GitHub Desktop.
Java - HashMap example : to get the name of today's month
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package neo.example;
import java.util.*;
/**
*
* @author neojou
*/
public class HashMapExample {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
HashMap<String,String> map = new HashMap();
map.put("1", "January");
map.put("2", "February");
map.put("3", "March");
map.put("4", "April");
map.put("5", "May");
map.put("6", "June");
map.put("7", "July");
map.put("8", "August");
map.put("9", "September");
map.put("10", "October");
map.put("11", "November");
map.put("12", "December");
Calendar calendar = Calendar.getInstance();
Integer month = new Integer(calendar.get(Calendar.MONTH)+1);
System.out.println("Today's Month :"+map.get(month.toString()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment