I am trying to convert String
to array then to an Integer
,i made code working successfully in java ,but in android studio the array the i converted don't take the last value of array covered from string
String y="abc";
String[] array = y.split("");
int[] x = new int[y.length()];
for (int i=0;i<y.length();i++)
{
String letter=array[i];
if( letter.equals("a")){x[i]=1;}
if( letter.equals("b")){x[i]=2;}
if( letter.equals("c")){x[i]=3;}
sum =sum + x[i];
}
sum variable always dont count the last value of conversation ,it should be 6 but i get 3