@Squiggs: A Map - doesn't allow duplicate keys. please look into below code, also. I thought it might also help you OR give you little more information. I have changed the input source string to 1234345|str1,1234346|str2,1234347|str3
and updated with extra lines, especially sysout
to print the memory values.
String source = "1234345|str1,1234346|str2,1234347|str3";
return Arrays.stream(source.split(","))
.map(s -> s.split("\\|"))
.collect( Collectors.toMap ( s -> { System.out.println(" 1: "+Long.valueOf ( s[0])); return Long.valueOf ( s[0]);} ,
s -> { System.out.println(" 2: "+s[1]);return s[1]; },
( (v1, v2) -> { System.out.println("------ line 131 : "+v1 +" "+v2); return v2 ;} )
)
);
with the above source you get output as: {1234346=str2, 1234347=str3, 1234345=str1}
If I change the source to source = "123434|str1,123434|str2,123434|str3"
, I get the output as {123434=str3}