Created
July 26, 2015 12:37
-
-
Save neojou/6c4a726bd16af4ff145f to your computer and use it in GitHub Desktop.
Java - HashMap example : to get the name of today's month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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