M.O.C
0
Q:

how to access contents of an array from another class in java

MyClass newClassObj = new MyClass();
int[] secondArray = newClassObj.getNumArray();
0
class MyClass
{
    //Variable I want to return
    private int[] numArray = {1, 2, 3};

    public int[] getNumArray() {
        return numArray.clone();
    }
 }
0

New to Communities?

Join the community