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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:42:06+00:00 2026-05-27T15:42:06+00:00

I have really stuck on two Java related issues. One simple and one more

  • 0

I have really stuck on two Java related issues. One simple and one more difficult.

Regarding the creation of a 2D array, I initialize a table like this:

private String [][] table_of_classifiers = null;

and then, within a function, I fill its contents like this:

        String [][] table_of_classifiers = {
            {"x1","x","x","x","x"},
            {"x2","x","x","x","x"},
            {"x3","x","x","x","x"},
            {"x4","x","x","x","x"},
            {"x5","x","x","x","x"},
            {"x6","x","x","x","x"},
        };

But as you can guess the second table overwrites (locally) the first one, that is of course not what I want to do. What I do wrong? Note that the dimension of the table is not known from the beginning.

  • 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-27T15:42:07+00:00Added an answer on May 27, 2026 at 3:42 pm

    Just do:

    class Foo {
        private String [][] table_of_classifiers = null;
    
        void bar() {
            table_of_classifiers = new String[][] {
                        {"x1","x","x","x","x"},
                        {"x2","x","x","x","x"},
                        {"x3","x","x","x","x"},
                        {"x4","x","x","x","x"},
                        {"x5","x","x","x","x"},
                        {"x6","x","x","x","x"},
            };
        }
    }
    

    Java doesn’t have eval (because it’s a compiled language), but it does have reflection. It’s almost certainly not the best approach to whatever it is that you want to do, though.

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

Sidebar

Related Questions

I am stuck with something quite simple but really annoying: I have an xml
I'm really stuck here. I have 2 issues at once: First, my site is
JAVA- Hi, I am writing a minesweeper program (first biggie) and am really stuck.
I have been trying these for past two days and getting stuck at same
After two days of searching, I'm stuck and could really use some assistance. I
I have two AsyncTasks that I am using, one is called up after a
I'm just learning Java... I have 2 custom classes. One is a Fraction and
I have been stuck on this one for a while - I couldn't figure
I have really basic question. How can I get form id by input element
I have really no idea why I'm asking this as this a really completely

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.