I am trying to search up to the right diagonally in my multidimensional array in java. Why am I getting index out of bounds error? -


I want to search through Java in my multidimensional array of characters. I have added an I statement to make sure that it stays within the range of the array, but I'm getting an index with a direct error. Can someone tell me what's wrong with my code?

  // search diagonal up to right if ((line - 1> = 0) & amp; amp; (col + 1> = board [col]] length) Found word = true; (Int letters = 0; Letters & lt; word.length (); Letters ++) {if (word.charAt (letter)! = Board [row - 1] [Col. + 1]) {foundWord = false; break; }} If foundWord {Return word + "found:" + Arrays.toString (new int [] {line, cola}); }} // end search diagonal right    

The array number starts with 0, therefore Here Colonel 1 and lieutenant; = Board [cola]. Length You should use the board [cola]. Length-1

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -