i have the following code
String[] alphabet = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z"};
if i do
String str = "aa";
for(int i=0;i<str.length();i++) {
chars.add(Arrays.asList(alphabet).indexOf(str.charAt(i)));
}
the values in chars are
0 = -1
1 = -1
as the result returned by Arrays.asList(alphabet).indexOf(str.charAt(i)) is 'a'97 and not "a" hence its not matching due to which -1 is being returned
I need Arrays.asList(alphabet).indexOf(str.charAt(i)) to return "a"
that's what i thought charAt returns which is just "a" and not this 'a' 97
any alternative ?