Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Bubble Sort Java? Using -1 after array.length

$
0
0
Hello

I am learning java and I am practising the bubble sort. I understand everything except.....

Could someone please explain the reason for using the -1 value after // numbers.length-1 in the 2nd for loop?


//more code here

for(int i=1; i<numbers.length; i++){

for(int j = 0; j < numbers.length-1; j++)

//more code here



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>