how to give access to an array from another class in java code example
Example 1: how to access contents of an array from another class in java
MyClass newClassObj = new MyClass();
int[] secondArray = newClassObj.getNumArray();
Example 2: how to access contents of an array from another class in java
class MyClass
{
//Variable I want to return
private int[] numArray = {1, 2, 3};
public int[] getNumArray() {
return numArray.clone();
}
}