I'm new to java and still learning, so keep that in mind. I'm trying to write a program where a user can type in a keyword and it'll convert it to numbers and put it in an array. My problem is the array needs to keep repeating the int's.
My code is:
String keyword=inputdata.nextLine();
int[] key = new int[keyword.length()];
for (int k = 0; k < keyword.length(); ++k)
{
if (keyword.charAt(k) >= 'a' && keyword.charAt(k) <= 'z')
{
key[k]= (int)keyword.charAt(k) - (int)'a';
}
}
Right now if I try to get any key[i] higher than the keyword.length it throws an outofbounds error. I need it to to be infinte.
So basically, if keyword.length() were 3 I need to be able to see if key[2] is the same as key[5] and key[8] and so on.
Thanks for your help!