Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何实例化双数组的特定值_Java_Arrays_Instantiation - Fatal编程技术网

Java 如何实例化双数组的特定值

Java 如何实例化双数组的特定值,java,arrays,instantiation,Java,Arrays,Instantiation,我试图在主类中实例化双数组。我需要使用3种不同的配置执行此操作: 1) 具有完整的双数组,如(字符串[],字符串[]) 2) 具有一个特定值,另一个具有类似双数组的值(字符串[],字符串[1][])) 3) 具有两个特定值,如(字符串[1][],字符串[1][]) 在我的代码中,我开发了两个类,谓词和主类(在这里我实例化了数组) 谓词类是 public class Predicate { //objects private static String[] airport = {"cdg","l

我试图在主类中实例化双数组。我需要使用3种不同的配置执行此操作:

1) 具有完整的双数组,如(字符串[],字符串[])

2) 具有一个特定值,另一个具有类似双数组的值(字符串[],字符串[1][]))

3) 具有两个特定值,如(字符串[1][],字符串[1][])

在我的代码中,我开发了两个类,谓词类(在这里我实例化了数组)

谓词类是

public class Predicate {

//objects
private static String[] airport = {"cdg","lhr"};
private static String[] loc = {"south","north"};
private static String[] city = {"paris","london"};
private static String[] pack = {"p1","p2"};
private static String[] vehicle = {"plane","truck"};

//types
private static String[][] place = {airport, loc, city};
private static String[][] physobj = {pack, vehicle};


List<String[][]> parameters = Arrays.asList(place, physobj);

public Predicate(String[][] p, String[][] p1 ) {

    p = this.place;
    p1 = this.physobj;

}

}
}

我试着让你喜欢

Predicate in = new Predicate(physobj[1][], physobj[1][]);
我收到了这个错误

  - Syntax error on token "[", Expression expected after 
   this token
  - Syntax error on token "[", Expression expected after 
   this token

如何为实例化选择双数组的特定值?

谓词的构造函数看起来不正确。为什么要将传入的参数指定给类变量?这就是选择特定于数组的值的问题吗?
  - Syntax error on token "[", Expression expected after 
   this token
  - Syntax error on token "[", Expression expected after 
   this token