i have written a code in java as given under
public class sstring
{
public static void main(String[] args)
{
String s="a=(b+c); string st='hello adeel';";
String[] ss=s.split("\\b");
for(int i=0;i<ss.length;i++)
System.out.println(ss[i]);
}
}
and the output of this code is
a
=(
b
+
c
);
string
st
='
hello
adeel
';
what should i do in order to split =( or ); etc in two separate elements rather than single elements. in this array. i.e. my output may look as
a
=
(
b
+
c
)
;
string
st
=
'
hello
adeel
'
;
is it possible ?
splitmethod I gave to suit your situation. Just include all the delimiters you have in that character class. In this case, you have\\W. So, you can use it. StringTokenizer may work, but it is not suggested to use it.