title: how to throw an exception if the object that is being added has a duplicate
body: <p>I have to add a new object to an array but throw an exception if that object already exists.I don't know what to add after 'throw___________;'.
  I have made the object class and also a class to hold an array of that object.I have also done the part where i have to add it to the array but i don't know what exception to throw if the object already exists in that array.   </p>