I'm trying to learn Java, but I have a problem with passing an array to constructor. For example:
Application class:
byte[][] array = new byte[5][5];
targetClass target = new targetClass(array[5][5]);
Target class:
public class targetClass {
/* Attributes */
private byte[][] array = new byte[5][5];
/* Constructor */
public targetClass (byte[][] array) {
this.array[5][5] = array[5][5];
}
}
I'd greatly appreciate it if you could show me how I can do that.
First, usually class names in Java starts with Upper case, now, to the problem you met, it should be:
public class TargetClass { /* Attributes */
private byte[][] array;
/* Constructor */
public TargetClass (byte[][] array) {
this.array = array;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With