you must use for (int i=0;i<result.length();i++)
then your problem will be solved