This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
THHIS IS RESOLVED I FORGOT THE '=' IN MY WHILE STATEMENT Howdy ya'll I writing an insertion sort and for some reason the first element of my sorted array isn't what it is supposed to be please help. this is the first few of my output
85925 56727 6849
85925 38 412 487 491 506 604 626
662 784 880 914 974 1271 1312 1451
1801 2231 2256 2346 2964 2974 3120 3169
Andrew Hodel wrote:THHIS IS RESOLVED I FORGOT THE '=' IN MY WHILE STATEMENT
Yeah. That's why you shouldn't write
It's too easy to make a tiny error and write this instead:
Which as you now know, doesn't do what you expected. So you should almost never compare boolean values against the literals true and false; you should just write
Joined: Apr 04, 2013
What are you talking about? My print was fine, I forgot to put <= so it wasn't comparing my first value in my sort method. But thanks for the little tid bit, that is a much cleaner way to write the if statement.