Mutables in a Set: Python vs Java

Set is a built-in data type present in both Python and Java but both of these languages handles the elements in a set differently. Though the underlying implementation of set is the same in both languages, Java lets you add mutable objects, such as a list to a set, whereas Python does not. Python Restricts Adding A List To A Set In python, when you try to add an entire list to a set, compiler throws an error:...

January 14, 2021 · 4 min · Me