O
opalpa
Hi, I'd like to make a routine that takes and array of arrays where the
second dimension is always two. I'm suprised that code like this
works:
package experiment;
public class MultiDimensionalArrays {
__private MultiDimensionalArrays() {}
____static public void main(String args[]) {
____String s[][] = new String[4][2];
____s[1][1] = "s"; // <-- new not needed for every inner array!
____System.out.println("string s? " + s[1][1]);
__}
}
I see that this code does not work:
package experiment;
public class MultiDimensionalArrays {
__private MultiDimensionalArrays() {}
__static void takeAr(String a[4][2]) {} // <-- not okay
__static public void main(String args[]) {
____String s[][] = new String[4][2];
____s[1][1] = "s"; // <-- new not needed for every inner array!
____System.out.println("string s? " + s[1][1]);
__}
}
How do you think about this?
second dimension is always two. I'm suprised that code like this
works:
package experiment;
public class MultiDimensionalArrays {
__private MultiDimensionalArrays() {}
____static public void main(String args[]) {
____String s[][] = new String[4][2];
____s[1][1] = "s"; // <-- new not needed for every inner array!
____System.out.println("string s? " + s[1][1]);
__}
}
I see that this code does not work:
package experiment;
public class MultiDimensionalArrays {
__private MultiDimensionalArrays() {}
__static void takeAr(String a[4][2]) {} // <-- not okay
__static public void main(String args[]) {
____String s[][] = new String[4][2];
____s[1][1] = "s"; // <-- new not needed for every inner array!
____System.out.println("string s? " + s[1][1]);
__}
}
How do you think about this?