2
String value = "good.day";
String splitValues[] = value.split(".");
System.out.println(splitValues.length);

The output of the above code is 0.I know that split method uses regex. So we have to use escape sequence "\" to make it work.But my question is why this output?. If . is a meta character which represents any character, we should get the length of the string as output isn't?

RamValli
  • 4,199
  • 2
  • 32
  • 43

1 Answers1

6

Remember when you split, the argument is removed. Thus, when all the characters are split, there are none remaining.

Malik Brahimi
  • 15,933
  • 5
  • 33
  • 65