I have an array of objects , now i want to add a new object to that array by checking if the value is unique . how ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I have an array of objects , now i want to add a new object to that array by checking if the value is unique . how ?

array of objects of another class

15th Jan 2017, 9:42 AM
Max Justice
Max Justice - avatar
4 Answers
+ 2
add the Comparable interface to you obj. and implement it.
15th Jan 2017, 10:25 AM
Andreas K
Andreas K - avatar
0
could u write a sample code for it . Please
15th Jan 2017, 10:27 AM
Max Justice
Max Justice - avatar
0
I'm in hurry today. Which is the reason that I only got you the official reference. Although I hope it helps. https://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html
15th Jan 2017, 1:08 PM
Andreas K
Andreas K - avatar
0
thank you for your help
15th Jan 2017, 1:18 PM
Max Justice
Max Justice - avatar