I'm getting frustrated with this substring function. Here my substring function giving me value first time only. It has been stored first 3 characters in arraylist. Second time it is not able to take other 3 characters and it has been stored " " value in arralist.
My code is below :
String mStr= "jklpourtujolkjth";
ArrayList mLst = new ArrayList();
for (int i = 0; i < mStr.length(); i+=3)
{
if ((i + 3) < mStr.length())
{
mLst.add(mStr.substring(i,3));
}
else{
mLst.add(mStr.substring(i));
}
}
Help me with this code. What's wrong with me?
Thanks,