I want to split a string like “p^q” into two strings, i.e. “p” and “q”. How can I do this using “string.split” in Java. I have used syntaxes like s.split("^"), s.split("\^"), and s.split("\\^") ! But the arraylist always has one element! Thanks
I want to split a string like p^q into two strings, i.e. p and
Share
prints
which proves that the array returned by
splithas not one, but two elements, and exactly those that you require.