Trying to split a string of space separated integers in java. To save time not converting the values to integers I wanted to do splitIntegers[i] == splitIntegers[i + 1]. However, I was unable to get any == to come out true even using splitIntegers[i] == "6", since 6 is the first integer stored in the array.
String sixString = "6 6 6";
String[] contains6 = sixString.split(" ");
boolean isSix = contains6[0] == contains6[1]; // is false was expecting true since should both be "6" and if I convert them to integers the values are allowed to be equal
boolean isSixString = contains6[0] == "6"; // is false
boolean areSixes = "6" == "6"; // is true, and can store "6" in a variable and get true
So something weird happens when you split a string in Java.
I am translating my knowledge of javaScript where my attempted solution works. Somehow I have an array of strings of 6 that do not equal a string litteral "6" or each other.
I am passing half the tests, and am sure I could speed things up If I did not have to convert the values I split into integers.