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

The solution for “how to access contents of an array from another class in java how to access contents of an array from another class in java” can be found here. The following code will assist you in solving the problem.

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

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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in