I have one doubt if this is or is not a good practice.
So immagine that you need to concatenate not defined number of arrays, and then at the end print the result. So immagine that you can call calculate a lot of times. E.g.
Object[] example = new Object [0];
public Object methodAppend(Object[] a, Object[] b){
- here append the array b to the array a
- return the array a
}
public Object calculate(){
Object[] someArray = new Object[5]
// immagine i already have some values in the array
for(int i=0;i<5;i++)
example = methodAppend(example,someArray)
return example
}
I get the wanted result. But my questions are:
Is this
example = methodAppend(example,someArray)
a good practice?
- How is called when I send the result of the method again in the method?
- Is this one example of recursion?
Because for recursion I always thought that is when e.g. for result we call the method again.
tnx