Array constructor references for multidimensional array

bitter_fox bitterfoxc at gmail.com
Tue May 7 21:09:30 PDT 2013


Hi,
Array constructor references had been supported by [1].

I have a question about multidimensional array constructor references.

In my example, I use a two dimensional array of int, but other
multidimensional arrays have a same problem.

We can write references for the one argument constructor of int[][]("new
int[x][]") by the change of [1]:

interface F1
{
    int[][] f(int a);
}

F1 f1 = int[][]::new;
f1.f(5); // means "new int[5][]"


We have another form of the array creation("new int[x][y]"), however the
compiler rejects references for it.

interface F2
{
    int[][] f(int a, int b);
}

F2 f2 = int[][]::new; // error
f2.f(5, 7);

Is this the expected behavior?

I think it would be accepted because we can consider them as a two argument
constructor and it should treat them like a constructor of other type which
is not array.

Is this already discussed?

Regards,
bitter_fox

[1]:
http://mail.openjdk.java.net/pipermail/lambda-dev/2013-January/007534.html


More information about the lambda-dev mailing list