import java.text.DateFormatSymbols; import java.util.Collections; import java.util.LinkedList; import java.util.List; public class Main { public static void main(String[] args) { List list = new LinkedList(); DateFormatSymbols dfs = new DateFormatSymbols(); String[] months = dfs.getMonths(); for (int i = 0; i < months.length; i++) { String month = months[i]; list.add(month); } Collections.sort(list); System.out.println("Month Names = " + list); int index = Collections.binarySearch(list, "October"); if (index > 0) { System.out.println("Found at index = " + index); String month = (String) list.get(index); System.out.println("Month = " + month); } } }