I am novice to java. I have an ArrayList and I want to avoid duplicates on insertion. My ArrayList is
ArrayList
ArrayList karList
You need to use any Set implementation, e.g you can use HashSet. If you want to add custom object kar into your HashSet, you need to override equals and hashcode method. You can read more about equals and hashcode, see
Set
HashSet
add
kar
override
equals
hashcode