If I had wanted to compare elements within an array what equation would I need to write? So for example,
for int[] sample = new int[5]
If sample[i], were to be put into a for loop and cycle through
for (int i = 0; i < sample.length-1; i++) { }
the output would be:
1st loop
sample[0] with sample[1]
sample[0] with sample[2]
sample[0] with sample[3]
sample[0] with sample[4]
2nd loop
sample[1] with sample[2]
sample[1] with sample[3]
sample[1] with sample[4]
3rd loop
sample[2] with sample[3]
sample[2] with sample[4]
4th loop
sample[3] with sample[4]
for int[] sample = new int[5]
If sample[i], were to be put into a for loop and cycle through
for (int i = 0; i < sample.length-1; i++) { }
the output would be:
1st loop
sample[0] with sample[1]
sample[0] with sample[2]
sample[0] with sample[3]
sample[0] with sample[4]
2nd loop
sample[1] with sample[2]
sample[1] with sample[3]
sample[1] with sample[4]
3rd loop
sample[2] with sample[3]
sample[2] with sample[4]
4th loop
sample[3] with sample[4]
1