I have a string array which contains "-" . So I have to split these strings to store them.
For example.
String s[]={"a","b","c","-","g","t","-","q","-","a","s","d","-","a","b","y"};
to
String k[]={"abc","gt","q","asd","aby"}
The code I have tried is
public static void main(String...a)
{
String s[]={"a","b","c","-","g","t","-","q","-","a","s","d","-","a","b","y"};
int sop=0;
String[] sdf=new String[100];
for(int kk=0;kk<s.length;kk++)
{
if(s[sop].equals("-"))
{
}
else
{
sdf[sop]=s[sop];
sop++;
}
}
}
But It gives first three string. abc. What I have to add?