Declare and Initialize Map in one line

 public static LinkedHashMap<String, Integer> MOVIES_CATEGORY_MAP =  
 new LinkedHashMap<String, Integer>() {{ 
     put(Constants.CATEGORY_ALL_IN_ONE, R.drawable.movies);
     put(Constants.CATEGORY_MOST_POPULAR_MOVIES, R.drawable.popular_movies);
     put(Constants.CATEGORY_HIGHEST_RATED_MOVIES, R.drawable.highly_rated_movies);
     put(Constants.CATEGORY_HIGHEST_RATED_MOVIES, R.drawable.highly_rated_movies);
     put(Constants.CATEGORY_POPULAR_KIDS_MOVIES, R.drawable.kids_movies);
     put(Constants.CATEGORY_UPCOMING_MOVIES, R.drawable.comingsoon);
   }};

Comments

Popular posts from this blog

@Overrride annotation introduced in Java1.5

Open-Closed Principle

S.O.L.I.D. Class Design Principles