Hello!
I am having trouble understanding how thing work with arrays specificly what the "=" operator represents. I've written a really simple code and I'm trying to fully understand what is happening, I am having a few doubts and some help would be appreciated. Thank you!
public class test { public static void main(String[]args) { int[] numbers = {1,2,3,4,5}; int temp; int start = 0;// first number in the array (1) int end = numbers.length -1;//last number in the array(5) while(start < end) {// keep going until the numbers "collide" temp = numbers[start];//temp now holds the value of start(1) numbers[start] = numbers[end];// this is the part that confuses me numbers[end] = temp;//this as well start = start + 1;// increase the value of start by 1 end = end -1;// decrease the value of end by 1 } Out.println(java.util.Arrays.toString(numbers)); } }