I currently have two String variables I check to find if they are duplicates:
Since red is not the same as yellow it would show "Not Duplicate".
Now how would I check 10 variables to find out if any of them are duplicates?
In this example red and green have duplicates.
Please advise how I can do this?
Code:
String str1 = "red";
String str2 = "yellow";
if (str1.equals(str2)){
System.out.println("Duplicate");
}
else{
System.out.println("Not duplicate");
}
Now how would I check 10 variables to find out if any of them are duplicates?
Code:
String str1 = "red"; String str2 = "yellow"; String str3 = "green"; String str4 = "blue"; String str5 = "red"; String str6 = "green"; String str7 = "green"; String str8 = "white"; String str9 = "black"; String str10 = "green";
Please advise how I can do this?
Comment