Question and answer is powered by AnsPress.io
I have a string called CString
and is in the form of something like this "Test$Test1"
.
Now I want to split the string. How can I do this in android?
I want to get like Test and Test1.
If you want to split string , you need to use split method for that.
android split string by $
String data = “Test$Test1”;
String[] items = data.split(“$”);
System.out.println(items[0].trim());
System.out.println(items[1].trim());
android split string by $
String data = “Test$Test1”;
String[] items = data.split(“\$”);
for (String item : items)
{
System.out.println(“item = ” + item);
}
or
System.out.println(items[0].trim());
System.out.println(items[1].trim());