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

  • SEARCH
  • Home
  • 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 6106221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:03:23+00:00 2026-05-23T14:03:23+00:00

I am making a maze solver. For some reason Everytime the line marked with

  • 0

I am making a maze solver. For some reason Everytime the line marked with ‘–>’ is reached, “Enter height: ” is outputted. It is like that line (which is not run when it is reached) somehow makes the method loop.

private void makeMap() {
    Map map; //used to convert the char array into a graph
    int height; //the height of the map by user input
    char[][] array; //used to store the char map

    System.err.println("Enter height: ");
    height = scanner.nextInt(); //gets and stores the height from the user

    array = new char[height][]; //initializes the map with input height
    for(int i=0; i<height; i++) { //adds row by row to the map array
        System.err.print("Enter next line of map: ");
        array[i] = scanner.next().toCharArray();
    }

    --> map = new Map(array); //initializes the map by passing the char array

    graph = map.makeGraph(); //creates a graph from the char array
  }

I labelled with ‘–>’ where I believe my problem lays. Any code i put before the marked line will execute, but as soon as that line is reached it loops back to the top of this method. Below is the Map constructor:

public Map(char[][] passMap) {
    adjList = new Vertex[map.length*map[0].length];
    map = passMap; //stores the passed map
}

ANY HELP is better than no help. I’ve been at this for hours. Thanks.

  • 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-23T14:03:23+00:00Added an answer on May 23, 2026 at 2:03 pm

    Your map variable is probably uninitialized. Change:

    adjList = new Vertex[map.length*map[0].length];
    

    To:

    adjList = new Vertex[passMap.length*passMap[0].length];
    

    I would also change your System.err.println() calls to System.out.println(). The first one is for error output, and the second one for normal console output.

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

Sidebar

Related Questions

Making an adobe flex ui in which data that is calculated must use proprietary
I would like to have a go at making some simple games for personal/learning
Goal I am making a program which generates a 3D maze and am having
I'm making another batch based video game and its like a maze game and
Making a small WCF test program which is based on a Store that has
Making UML sequence diagram in VS 2010RC I've observed that there is no activation
After making some changes in my models (eg. new field in a model and
When making software, specially games, those resources like graphics and sounds are something freaky
Making a flash page that can cycle through these three images on mouseclick. For
Making an Flex App. Just wondering if anyone has created something that fits automatically

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.