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 8409331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:52:44+00:00 2026-06-09T23:52:44+00:00

all I am interesting learning how to achieve a 2d String [][] array console

  • 0

all
I am interesting learning how to achieve a 2d String [][] array console printout using only native, pure java. The following code prints out a 2d matrix when I run my program, but one particular line was confusing while doing some test runs on converting my string to a 2d array:

rulesTable[i][j] = rulesMatrix[j];

Is there a way I could code this wherein rulesMatrix would be = to a 2d String array instead of the 1d String array I currently have? Any tips would be great. Thank you. The following snippet contains the loop-in-question:

protected void forgeGrammar()
{

    //this verifies that all 5 rules displayed in the console are valid
    grammarRules = new String(startingRule + secondRule + thirdRule + fourthRule + fifthRule);

    rulesArray = new String[grammarRules.length()];

    //remove the commas from the grammar  
    rulesArray = grammarRules.split("[,]");

    //convert the grammar to a 2D String array
    rulesTable = new String[rulesArray.length][5];
    for (int i = 0; i < rulesTable.length; i++)
    {
        String[] rulesMatrix = rulesArray[i].split(blank);

        for(int j = 0; j < rulesMatrix.length; j++)
        {
            rulesTable[i][j] = rulesMatrix[j];
        }
    }
  • 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-06-09T23:52:46+00:00Added an answer on June 9, 2026 at 11:52 pm

    In your code rulesTable Never gets initialized that’s why NullPointer exception is thrown at below line

    rulesTable[0][0].contains(rules_input.substring(0, 4));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to find all interesting links in a page: soup.findAll('a', href=re.compile('^notizia.php\?idn=\d+'))
I'm learning about threads in Java right now, along with all the concepts and
Only with standard gcc Objective-C headers. Most of all I am interesting in arrays
I am interesting in removing all the text within the following tags: <p class=wp-caption-text>Remove
I have a window with 3 radiobuttons like this(removed all non interesting props): <Control
So I have been running into all kinds of interesting problems in VisualStudio 2008
This is pretty interesting, this site runs a speed test and compares all of
I have some interesting problem for an hour.. In my flex project, all width
All, If I run a query like the following: $qry = Select wrong_column from
All, If I've go the following database fields/values: user_id field_name field_value 1 EventHour1 1

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.