首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

请问 : 三维数组有关问题

2012-02-27 
请教 : 三维数组问题public demo extends Frame{private String str[][][] {{ {,},{,},{,}..

请教 : 三维数组问题

public demo extends Frame
{
  private String str[][][] =
  {
  { {"",""},{"",""},{"",""}... },
  { {"",""},{"",""},{"",""}... },
  ...
  };
  public demo()
  {
  ...
  for(int j=0;j<str[index1][index2].length;j++)
list3.addItem(str[index1][index2][j],j);  
  }
}
编译报错:
  ---------- javac ----------
Demo.java:222: local variable str is accessed from within inner class; needs to be declared final
for(int j=0;j<str[index1][index2].length;j++)
Demo.java:222: array required, but java.lang.String found
for(int j=0;j<str[index1][index2].length;j++)

Demo.java:223: local variable str is accessed from within inner class; needs to be declared final 
  list3.addItem(str[index1][index2][j],j);
Demo.java:223: array required, but java.lang.String found
list3.addItem(str[index1][index2][j],j);

4 errors

哪位大侠指教!!!

[解决办法]
As you know the inner class exists for its own purpose, it needs a "final" modifier. Just like you want to initialize a variable once and want it immutable, you can use "final":

Java code
final static int SIZE = 10;
[解决办法]
local variable str is accessed from within inner class; needs to be declared final 
其实就是这个错,把你的代码粘出来看看,大致意思就是内部类访问不了局部变量,需要定义成final的。
[解决办法]
探讨
local variable str is accessed from within inner class; needs to be declared final
其实就是这个错,把你的代码粘出来看看,大致意思就是内部类访问不了局部变量,需要定义成final的。

热点排行