Tony Wolff
Tony Wolff

Reputation: 742

How to reference a subarray of a two dimensional array as a single dimensional array in java

I have a two dimensional array myArray[a][b] what is the most elegant way of referencing the single dimension array myArray[a][2] in Java.

Upvotes: 1

Views: 112

Answers (1)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 136062

If I understood question correctly, this is it

    int a[][] = {{1,1,1},{2,2,2}, {3,3,3}};
    int[] a2 = a[2];

,

Upvotes: 1

Related Questions