I was working on String
and tried with split()
for .
like:-
String s = "Hi.Hello";
System.out.println(Arrays.toString(s.split(".")));
The above code outputs []
empty array. But if I escape .
like :-
String s = "Hi.Hello";
System.out.println(Arrays.toString(s.split("\\.")));
Its giving correct output as [Hi, Hello]
.
So I Want To Know:-
Why do i need to escape .
but .
it is normally not considered a escape character in String
as we can use .
directly.