Consider a while loop that goes on for the entire life of the program. You have a String arraylist and for every String in array, you will compare it with every object from the array.
I'm not sure if this part matters, but assuming each object has a .getString() method which you compare with the String in the arraylist.
ArrayList<String> stringArray = new ArrayList<>()
stringArray.add("hello"); // 0th element
.
.
.
stringArray.add("bye"); // mth element
while(true){
//assume that you HAVE to instantiate a new object array every loop
Object[] objectArray = {new object(), .....new object() };
for(Object i : objectArray){
if stringArray.contains(i.getString())
return true;
}
}
If i'm not mistaken this operation takes O(m*n) time? the string arrayList would have m number of elements and the object array would have an n number of elements. Does the time complexity also play a factor in cpu usage?