I am having a few problems in getting a method to work properly in Java. In the program I have created an array consisting of many different words of different length. The met
If you have replaced
for (int index = 0; index < wordTable.length; index++) {
with
for (int index = 0; index < length; index++) {
that is most likely not what you really want.
The better approach would be like this:
public static void inputMethod(int length, char letter, int position) {
// check if input is valid
if(position < length)
for (int index = 0; index < wordTable.length; index++) {
if (length == wordTable[index].length() && letter == wordTable[index].charAt(position) )
System.out.println(wordTable[index]);
}