I am not 100% sure if this is a relevant question around here, but I find this thing interesting.
When splitting a string into an array of strings in Java like this:
String[] array = "yolo".split("");
The implementation in Java 7 and Java 8 is a little bit different.
In Java 8: array.length is 4 and the array looks like this ["y","o","l","o"]
In Java 7: array.length is 5 and the array looks like this ["","y","o","l","o"]
Is this a bug that wasn't fixed until Java 8 (I seem to remember that you would get Java 7 result in older versions of Java aswell)?
Shouldn't code like this be backward compatible, which means that the method should return the same result in Java 7 and Java 8?
""as first result of split on""(or other zero-width regexes) people in 99.9% of cases ware either removing this first element, or trying to avoid creation of such result by splitting on something like(?<!^)- this will check if empty string we are splitting on is not at start of input.