Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:40:03+00:00 2026-05-27T11:40:03+00:00

When I try to run my program, it gives the following error… Exception in

  • 0

When I try to run my program, it gives the following error…

 Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 3
    at java.lang.String.charAt(Unknown Source)
    at Woordzoeker.check(Woordzoeker.java:88)
    at Woordzoeker.main(Woordzoeker.java:8)

I understand that the String probably went over the boundaries of an array, but I can’t seem to understand why. Could someone please assist me to understand the problem.

This is my code…

public class Woordzoeker {
    public static String[] words = {"boom","ma","maat","kas","kast","as","boek","boot"};
    public static String[][] grid = {{"b","o","e","k"},{"o","o","z","a"},{"o","j","o","s"},{"m","a","a","t"}};
    public static String[][] gridz = new String[4][4];

    public static void main(String[] args) {
        for (int x=0; x < words.length-1; x++){
            System.out.println(words[x] + " --> " + check(words[x],grid));
        } // THIS IS LINE 8
        System.out.println(isCorrectGrid(grid));
        System.out.println(isCorrectWords(words));
        }

public static int[] check(String word, String[][] grid){
    int[] array = new int[3];
    int y = 0;
    for (int rij=0; rij < grid.length; rij++){
        for (int kolom = 0;kolom < grid[rij].length; kolom++){
            for (int x=0; x < words.length - 1; x++)
                if (words[x].charAt(y) == (grid[rij][kolom].charAt(0))){  // THIS IS LINE 88
                    array[0] = rij;
                    array[1] = kolom;  // slaat de begin coordinaten op
            for (y = 0; y < words[x].length() - 1; y++){
                if (words[x].charAt(y) == grid[rij + y][kolom].charAt(0)){
                    array[2] = 1;
                }
                if (words[x].charAt(y) == (grid[rij][kolom + y].charAt(0))){
                    array[2] = 2;
                }
                if (words[x].charAt(y) == (grid[rij + y][kolom + y].charAt(0))){
                    array[2] = 3;
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:40:04+00:00Added an answer on May 27, 2026 at 11:40 am

    Maybe you should clear y after last for?

    for (y = 0; y < words[x].length() - 1; y++){
       if (words[x].charAt(y) == grid[rij + y][kolom].charAt(0)){
       array[2] = 1;
       }
       if (words[x].charAt(y) == (grid[rij][kolom + y].charAt(0))){
       array[2] = 2;
       }
       if (words[x].charAt(y) == (grid[rij + y][kolom + y].charAt(0))){
       array[2] = 3;
       }
    
    }
    y=0;
    

    check it

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when I try to run my program. Any reasons
When I try to run the following, I get an error back from ActiveRecord
When i try to run this #sqlplus system@orcl it gives me this error SQL*Plus:
I try to run one program in myeclipse where after creating one web project
I try to run jsf application in myeclipse using jboss web server and following
When I try to run the following code (from the REPL) in Clojure: (dotimes
whenever I try to run something in Java, Eclipse changes into the PHP perspective.
Am trying to run the following python program import re regex=re.compile(http...imgs.xkcd.com.comics.[\\S]*.[jpg|png]) f=open('out.txt') for a
When I try to run a .NET assembly ( boo.exe ) from a network
Every time I try to run a small application that uses a Derby DB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.