list - Is it better to use generics or Object type for a static helper class in Java? -
i writing program other day required me to: frequency of particular object inside arraylist<string> , remove occurrences of given item, etc., etc. not specified list interface. decided write own helper class , wanted make reusable possible. decided specify list parameter type of collection use class implementing list interface. these classes defined using generics, , did not know class type item removed be. either had define static helper methods generically since static class can not contain generic types explicitly, or define class type of object removed object . implemented in both ways, see below, wondering if there benefits using 1 on other. some further questions on topic: why able work around reference of generic type in static context defining in method header rather class header? when using static method, why not have declare class type in usage? i.e. listtools_v2.getfrequencyof(arraylist<string> items, string s) still works. implementation using ...