Say I have an array of primitives or a list of objects, it doesn't matter if there is a short way to do this check:
if (a_primitive == any_item_in_my_collection) { // do something }
or
if (an_object_ref.equals(any_item_in_my_collection)) {
without doing this
for (int i = 0; i < myArray.length; i++) { if (a_primitive == myArray[i]) {
Thanks!
source share