将2D数组添加到数组的数组列表

时间:2017-03-20 03:57:47

标签: java arrays

编辑:数组列表声明:

List<String> shapeList = new ArrayList<String>();

我正在尝试使用数组列表创建一个2D数组数组。

shapeList.add(drawBoxClassObject.drawBox(l));

其中drawBoxClassObject.drawBox(l);返回一个二维字符串数组,这一行给出了这个错误:

no suitable method found for add(String[][])
method Collection.add(String) is not applicable
  (argument mismatch; String[][] cannot be converted to String)
method List.add(String) is not applicable
  (argument mismatch; String[][] cannot be converted to String)

如何将二维字符串数组本身存储在一维字符串数组中(我认为可以修复它不能转换为字符串)?

3 个答案:

答案 0 :(得分:0)

更改Status of node rabbit@localhost ... Error: unable to connect to node rabbit@localhost: nodedown DIAGNOSTICS =========== attempted to contact: [rabbit@localhost] rabbit@localhost: * connected to epmd (port 4369) on localhost * epmd reports: node 'rabbit' not running at all other nodes on localhost: ['rabbitmq-cli-77'] * suggestion: start the node current node details: - node name: 'rabbitmq-cli-77@Ling-Air' - home dir: /Users/Ling - cookie hash: 0YMYFZ/TBrgNjOy7lBAw4A== 的声明
shapeList

List<String> shapeList = new ArrayList<>();

答案 1 :(得分:0)

您的错误表明您的shapeList初始化有点像这样:

List<String> shapeList = new ArrayList<>();

但是如果你想存储drawBoxClassObject,那么你需要更改声明以接受2D字符串数组,如下所示:

List<String[][]> shapeList = new ArrayList<>();

答案 2 :(得分:0)

这应该有效:

    List<String[][]> shapeList = new ArrayList<String[][]>();

你把String [] []放在一个字符串上。