String str="a*nice*day";
String res="";
int j=0;
for(int i=0;i<str.length();i++)
{
if(str.charAt(i)=='*')
{
j=i++;
break;
}
}
while(str.charAt(j)!='*')
{
res=res+str.charAt(j);
j++;
}
System.out.println(res);
Here i'm trying to extract the word "nice" without using substring method...and whats wrong with this program?