I am looking to create a map of character as a key and value as a list of string using Java8 stream mechanism.
The input is like, set of strings: ["hi","hills","and","at","not","bad","that","the"] The output like, map of character and list of string: ['h':["hi","hills"], 'a':["and","at"], 'n':["not"], 'b':["bad"], 't':["that","the"]]
I am able to do it in using earlier java version but stuck with creattion on this on Java8 using stream.
1) You don't need to use the map(s -> s.toString()). parseDataSet is a Set<String>, so s is already a String. Note that you could also have used map(Object::toString).
2) Never use new Character(...) or any of the other primitive wrapper class constructors to wrap a primitive. If possible, don't wrap manually but use auto-boxing instead: s -> s.charAt(0). If you really need explicit boxing, use the valueOf method: s -> Character.valueOf(s.charAt(0)). The reason is that valueOf will use a cached instance for specific ranges; at least -128 to 127 (inclusive) for all numeric types, and at least \u0000 to \u007F for characters. FYI, that's the entire ASCII character set (see http://www.asciitable.com/).
Also, be very carefull to incorporate fields into the 'equals' method that can be changed at will. As it is now you cannot guatantee that WordDate x equals WordData y need not have the same outcome at every given moment, against the contract of 'equals'.