help needed on split function

Hi All,

i have a small code :-

String selecteID = "QP|10009";

String radioId []= selectedID.split("|");

int i = 0 ;

System.out.println("radioId[0] ="+radioId);

System.out.println("radioId[1]= "+radioId[++i]);

Its output is

radioId[0]=

radioId[1]=Q

However i wanted the code to return ans as :--

radioId[0]=QP

radioId[1]=10009

Why does the split function does not work for '|' ? Or we cannot use '|' in case of split functions.

[524 byte] By [java_freshera] at [2007-11-27 7:59:26]
# 1
Escape the pipe char, it means "OR" in regex:split("\\|")
quittea at 2007-7-12 19:41:29 > top of Java-index,Java Essentials,Java Programming...
# 2
thanks a lot for the help !
java_freshera at 2007-7-12 19:41:29 > top of Java-index,Java Essentials,Java Programming...
# 3
Personally I prefer split("[|]")coz I hate trying to read RE's full of those dang \\'s;-)Keith
corlettka at 2007-7-12 19:41:29 > top of Java-index,Java Essentials,Java Programming...