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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:22:02+00:00 2026-06-07T00:22:02+00:00

I need to be able to search through multiple 2D arrays and search the

  • 0

I need to be able to search through multiple 2D arrays and search the data in the array and compare it to the data being put into the method when it is called. I tried to use .getClass().getSimpleName() however that only returns int[][] which all of the arrays i am searching through are of this type so it will not help me distinguish between them.

I am using this series of code to determine the proper array to call:

 public void tempSelection78 (int fRate, int wbTemp, int rcTons, int a, int r)
  {
    setTitle(TONS_05_78.getClass().getSimpleName());
     for (int model = 0; model < 7; model++)
    {
      String tonChart = tons78FCharts[model];
      for (int col = 0; col < 9; col++)
      {
        for (int row = 0; row < 8; row++)
        {
          int t = 0;

          if (tonChart.equals(TONS_03_78.getClass().getSimpleName()))
          {
            t = TONS_03_78[col][row];
          }
          if (tonChart.equals(TONS_04_78.getClass().getSimpleName()))
          {
            t = TONS_04_78[col][row];
          } 
          if (tonChart.equals(TONS_05_78.getClass().getSimpleName()))
          {
            t = TONS_05_78[col][row];
          }
          if (tonChart.equals(TONS_07_78.getClass().getSimpleName()))
          {
            t = TONS_07_78[col][row];
          }
          if (tonChart.equals(TONS_09_78.getClass().getSimpleName()))
          {
            t = TONS_09_78[col][row];
          }
          if (tonChart.equals(TONS_11_78.getClass().getSimpleName()))
          {
            t = TONS_11_78[col][row];
          }
          if (tonChart.equals(TONS_15_78.getClass().getSimpleName()))
          {
            t = TONS_15_78[col][row];
          }
          if (rcTons == t)
          {
            tableButton = new JButton(new ImageIcon(tablesFor78[model], tablesFor78[model]));
            break;
          }
          else 
          {
            tableButton = new JButton(new ImageIcon("CANNOT_FIND_MODEL.GIF", "SCROLL"));
          }
        }
      }
    }
    for (int model = 0; model < 7; model++)
    {
      String flowChart = flow78FCharts[model];
      for (int col = 0; col < 9; col++)
      {
        for (int row = 0; row < 8; row++)
        {
          int t = 0;
          if (flowChart.equals(FLOW_03_78.getClass().getSimpleName()))
          {
            t = FLOW_03_78[col][row];
          }
          if (flowChart.equals(FLOW_04_78.getClass().getSimpleName()))
          {
            t = FLOW_04_78[col][row];
          } 
          if (flowChart.equals(FLOW_05_78.getClass().getSimpleName()))
          {
            t = FLOW_05_78[col][row];
          }
          if (flowChart.equals(FLOW_07_78.getClass().getSimpleName()))
          {
            t = FLOW_07_78[col][row];
          }
          if (flowChart.equals(FLOW_09_78.getClass().getSimpleName()))
          {
            t = FLOW_09_78[col][row];
          }
          if (flowChart.equals(FLOW_11_78.getClass().getSimpleName()))
          {
            t = FLOW_11_78[col][row];
          }
          if (flowChart.equals(FLOW_15_78.getClass().getSimpleName()))
          {
            t = FLOW_15_78[col][row];
          }
          if (fRate == t)
          {
            tableButton = new JButton(new ImageIcon(tablesFor78[model], tablesFor78[model]));
            break;
          }
          else 
          {
            tableButton = new JButton(new ImageIcon("CANNOT_FIND_MODEL.GIF", "SCROLL"));
          }
        }
      }
    }

what i want to happen is the tonChart be set to one of the strings containing the possible 2d arrays to search through which it does. However the .getClass().getSimpleName never gets set to anything other than int[][] and causes the program to always divert to the else statement at the end of each triple nested loop.

any suggestions?

Here is an example of the arrays that are called:

public final int [][] TONS_03_78 = 
  {{27, 32, 37, 41, 45, 48, -1, -1, -1},
    {-1, 41, 45, 50, 55, 59, 64, 68, 70},
    {-1, 49, 55, 60, 65, 70, 75, 80, 85}, 
    {-1, -1, 64, 70, 75, 81, 86, 91, 97},
    {-1, -1, -1, 80, 86, 92, 98, 103, 109},
    {-1, -1, -1, -1, 97, 103, 109, 116, 122},
    {-1, -1, -1, -1, -1, 114, 122, 128, 135},
    {-1, -1, -1, -1, -1, -1, -1, -1, -1}};
  public final int [][] FLOW_03_78 = 
  {{205, 160, 137, 122, 112, 103, -1, -1, -1},
    {-1, 203, 170, 150, 137, 127, 120, 113, 105},
    {-1, 245, 205, 180, 163, 150, 140, 133, 127}, 
    {-1, -1, 240, 210, 188, 173, 162, 152, 145},
    {-1, -1, -1, 240, 215, 197, 183, 172, 163},
    {-1, -1, -1, -1, 242, 220, 205, 193, 183},
    {-1, -1, -1, -1, -1, 245, 228, 213, 202},
    {-1, -1, -1, -1, -1, -1, -1, -1, -1}};
  • 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-07T00:22:04+00:00Added an answer on June 7, 2026 at 12:22 am

    I’d change your Paradigm.

    I’m not entirely sure what your specific problem is, so the following approach might change, but If I were you, I’d build a class or a struct which contains a 2-d array and then some sort of identifier. (it can be a string, or an int, or an enum, or whatever else you want).

    Not only will that kind of approach reduce your code size, but It will make it more readable for both you and us.

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

Sidebar

Related Questions

I need to be able to search through the dictionary by zipcode but I
I need to be able to search through a log and grab IP addresses
I need to be able to search within a string and find out if
I have a program that I need to be able to search a file
I need to be able to programatically expand users' search expressions such as: X
Need to be able to pull Magento products into an external template. Need to
I work for a medical lab company. They need to be able to search
Is there a performant way in PHP to search for a file through multiple
When one visits http://maps.google.com , they are able to type queries into the search
I need to be able to Search a directory and its subdirectories for specific

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.