-1
public class warm4{

  public static void main(String[] args){
     double scale = 3;
     double[] array = {1,2,3};
  }
    public static double[] scalarMultiply(double[] array, double scale){
      for( int i=0; i>array.length; i++){
      array[i] = (array[i])*scale;
      }
      return array[]; **//error here!**
     }
  }

我不知道如何纠正这个错误!

先感谢您!

4

2 回答 2

0
  return array; **// Now no error here!**

No need for that extra [].

[] is a syntax part of array declaration time to specify length of array.

So need to add that while returning that array. Just use variable name.

于 2013-10-29T13:51:21.143 回答
0

array[] doesn't make sense.
If you want to return the value of a variable, just return that variable.

于 2013-10-29T13:51:37.600 回答