If I had the following declaration of the list:
List< Integer> b = new ArrayList< Integer>();
and
List< HashSet < Integer>> c = new ArrayList< HashSet< Integer>>();
I was wondering how would I be able to add b to c?
I’ve tried c.add(b);
but this doesn’t work.
Thanks for any help!
You cant add a
HashSetof integers to a list of integers. They’re two different datatypes. If you would have aHashSetof integers instead of a List of integers, then you would be able to add them to your list.like this: