I have 2 Java Classes.
class A {
String name;
List<B> numbers;
}
class B {
Integer number;
}
I want to get the distinct of Class A and concat the List of B in it.
e.g. Suppose I have a List with the following objects.
List<A>{
name = "abc"
List<B>{1,2}
name= "xyz"
List<B>{3,4}
name = "abc"
List<B>{3,5}
}
The result should be:
List<A>{
name = "abc"
List<B>{1,2,3,5}
name="xyz"
List<B>{3,4}
}
Any help would be appreciated.
Note: I want to achieve this functionality using Java 8 streams.
Thanks