所以我需要从正在处理的函数中返回多个数组。问题是我不知道要使用哪个函数值? (例如int函数,字符串函数等)另外,如何返回多个值?我需要从arrayGen()到barriers()发送障碍和障碍。谢谢你的帮助!

最后:

int barriers(){
    if (R == 1){
        while (size>0){
            barrierx[size-1] = randomInt(512);
            barriery[size-1] = randomInt(512);
            size = size - 1;
        }

       while (sizeC>0){
           ellipse( barrierx[sizeC-1],  barriery[sizeC-1], 100, 100);
           sizeC = sizeC - 1;
       }
       sizeC = sizeB;
       R = 0;
    }
    return 5;
   }

  int arrayGen(){
      int size = randomInt(11);
      int sizeB = size;
      int sizeC = size;

      int[] barrierx = new int[size];
      int[] barriery = new int[size];
  }


编辑:

int arrayGen(){

  int size = randomInt(11);
  int sizeB = size;
  int sizeC = size;
  int[] result = new int[2];

  int[] barrierx = new int[size];
  int[] barriery = new int[size];

   while (size>0){
    barrierx[size-1] = randomInt(512);
    barriery[size-1] = randomInt(512);
    size = size - 1;
  }


  result[0] = barrierx;
  result[1] = barriery;
return result;
}


类型不匹配无法从int []转换为int

最佳答案

定义一个包含您需要的所有数据字段的类。然后返回该类的对象。

关于java - 通过函数返回多个数组(处理),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37613165/

10-08 22:02
查看更多