I want to find out if the shared comma string contains only the same values:
test,asd,123,test test,test,test
Here the second line contains only the word "test". I would like to identify these lines.
Since I want to iterate over 100 GB, performance matters a lot.
What could be the fastest way to determine the result of a boolean if the string contains only one value repeatedly?
public static boolean stringHasOneValue(String string) { String value = null; for (split : string.split(",")) { if (value == null) { value = split; } else { if (!value.equals(split)) return false; } } return true; }
source share