setter and getter of multidimensional array

I have class test2 with an 3D array named as decision_variable. I define setter and getter for this array.I'm not sure is correct or not and then in the main class I want to set value for example  decision_variable [1][1][1]=1

public class test2 {

private int[][][] decision_variables = new int[3][3][2];

public test2() {


public test2(int[][][] decision_variables) {


this.decision_variables = decision_variables;


public int[][][] getDecision_variables() {

return decision_variables;


public void setDecision_variables(int[][][] decision_variables) {

this.decision_variables = decision_variables;





public class main {

public static void main(String[] args) {

test2 dv=new test2();

dv.setDecision_variables([1][1][1]=1);// Having Error

dv.getDecision_variables([1][1][1]);//Having Error



Read More »

By: coderanchbeginnerjava - 7 days ago

Related Posts