我需要能够搜索多个二维数组并搜索数组中的数据,并将其与调用时放入方法中的数据进行比较。但是,我尝试使用.getClass().getSimpleName()
仅返回int[][]
我正在搜索的所有数组都属于这种类型,因此它不会帮助我区分它们。
我正在使用这一系列代码来确定要调用的正确数组:
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"));
}
}
}
}
我想要发生的事情是tonChart
设置为包含可能的二维数组的字符串之一,以通过它进行搜索。然而,.getClass().getSimpleName
永远不会被设置为除此之外的任何东西,int[][]
并导致程序总是在每个三重嵌套循环结束时转移到 else 语句。
有什么建议么?
以下是调用的数组的示例:
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}};