Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;
import java.util.HashMap;

import java.util.Map;

public class Main {

    public static <T> Map<T, Integer> groupCount(Collection<T> data) {
        Map<T, Integer> group = new HashMap<T, Integer>();
        if (data != null) {
            for (T x : data) {
                int value = group.get(x) == null ? 1 : group.get(x) + 1;
                group.put(x, value);
            }
        }
        return group;
    }
}