I have this method that doubles my initial array and then returns it as the new array. When I then reprint the new array, it doesn't show that it doubled. I will paste just the single method, but if it's not enough, let me know. It will print it correctly in the method when I use the second for loop, but when I call the method to print the array, it prints the initial array.
public static int [] doubleArray(int [] p)
{
int [] newArr = new int [p.length * 2];
for (int i = 0; i < p.length; i++)
{
newArr[i] = p[i];
}
p = newArr; //Here I set the new doubled array to equal the array in parameters
for (int i = 0; i < p.length; i++)
{
System.out.print(p[i] + " ");
}
return p;
}
p = newArrbut rather just use the newArr array to avoid reader confusion.