I have read the String.split
Javadoc, and I also read How to split a string in Java
I was trying this code, and my delimiters are
!,?._'@
However, it doesn't split
. What's wrong with my code?
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args)
{
String[] tokens = "He is a very very good boy, isn't he?".split(" !,\\?\\._'@");
for (String token : tokens){
System.out.println(token);
}
}
}
The output should be
He
is
a
very
very
good
boy
isn
t
he
But instead, I get
He is a very very good boy, isn't he?