Considering I have two arrays for example:
String[] array1 = new String[10];
int[] array2= new int[10];
So that inside a method I’ve computed two arrays, namely array1 & array2
and now I want to return both of these arrays. How should I go about it?
I read here that I can make another class and define certain object types and encapsulate these arrays in that class constructor, but I’m still confused and did not understand completely.
If you could show me a working example which does that, or may be any similar idea, it would be good.
You can actually return something like this also:
And let’s say outside where you call this method your returned object is
obj. Then get access to array1 asobj[0]and access array2 asobj[1](proper casting will be needed).