日期:2014-05-20  浏览次数:20661 次

为什么下面的程序说我"keysTocutBysections = {{}}"非法表达式开始
为什么下面的程序说我"keysTocutBysections = {{}}"非法表达式开始?


public class GetAllContent {
  String address;
  String[][] keysTocutBysections;
  public String GetAllCont (String addr, String keyword) {
  address = addr;
  if (address.indexOf("9") != -1) {
  keysTocutBysections = {{}};
  }
  return "0";
  }
  public static void main(String[] args) {
  GetAllContent xx = new GetAllContent();
  xx.GetAllCont("99", "0");
   
  }
}

------解决方案--------------------
哦 不好意思 刚才没细心看 这个应该是数组静态初始化的时候 应该在声明数组的时候同时进行初始化
Java code
String address;
   public String GetAllCont (String addr, String keyword) {
  address = addr;
  if (address.indexOf("9") != -1) {
  String[][]  keysTocutBysections = {{}};
  }
  return "0";
  }
  public static void main(String[] args) {
  GetAllContent xx = new GetAllContent();
  xx.GetAllCont("99", "0");
    
  }