title: Java 8 - Streams API - Operating on LIST
body: <p>I have an ArrayList which contains the following - CHENNAI, MUMBAI, DELHI, CHENNAI, DELHI, CHENNAI. Also, assume that these 3 city names are defined as an ENUM with a value against each city. (CHENNAI=1, MUMBAI=2 AND DELHI=3)</p>
  
  <p>My Java 8 Streams, I am able to compute the sum of city values which in this case would be 1+2+3+1+3+1 = 11.</p>
  
  <p>Question I have is, how can I compute the sum of city values for the same ArrayList if there is an additional criteria which says,</p>
  
  <p>if a city name appears twice, it must be added only once. i.e. in this case CHENNAI is present 3 times. So, when adding its value we should consider only 1 (for the first 2 occurrences) + 1  = 2 instead of 3. Similarly, DELHI is present 2 times. So, value of Delhi should be taken only once.
  Hence the end result would be 2+2+3 = 7 instead of 11 as I explained before.</p>
  
  <p>Please help how to to achieve this in Java 8</p>