Why is it that in the following, the output is [] and not [1]?
[]
[1]
String input=\"1|2|3\"; String[] values= input.split(\"|\"); System.
Try using \\| instead of | when you split as you need to escape it.
\\|
|
So your code would change to:
String input="1|2|3"; String[] values= input.split("\\|"); System.out.println("[" + values[0] + "]");