import java.util.StringTokenizer;
class MySplit
{
public static void main(String S[])
{
String settings = "12312$12121";
StringTokenizer splitedArray = new StringTokenizer(settings,"$");
String splitedArray1[] = settings.split("$");
System.out.println(splitedArray1[0]);
while(splitedArray.hasMoreElements())
System.out.println(splitedArray.nextToken().toString());
}
}
In the above example, if I split the string with $, then it doesn't work fine, and if I split it with another character, then it works fine.
Why this is so, if it supports only the expression of a regular expression, why it works fine for :, ,, ;etc. characters.
source
share