+ 1

Method split

String x = "programming_is_fun!_"; String[] array = x.split("_"); Why doesnt the last _ save an empty string in the array? Thanks for your help

22nd Oct 2020, 6:45 PM
Manfred h
2 Respuestas
+ 3
Since last character _ is a separator and there is nothing after it, no element is created in the array. Empty string does not equal to nothingness (null). It is actually a regular string, just without any characters.
22nd Oct 2020, 7:34 PM
Aleksandrs
Aleksandrs - avatar
0
Thank you
22nd Oct 2020, 7:38 PM
Manfred h