Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Map<String,Integer> getCategoryCounts () {
- Map<String,Integer> categoryCounts = new HashMap<String,Integer>();
- for (BlogPost post: mPosts) {
- String category = post.getCategory();
- Integer count = categoryCounts.get(category);
- if(count == null){
- count = 0;
- }
- count++;
- categoryCounts.put(category, count);
- }
- return categoryCounts;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement