reset password
Author Message
RandomAccess
Posts: 101
Posted 21:59 Mar 15, 2018 |

For some reason, this one while loop I'm trying to use to sort the linked list isn't working at all, as in it's not even being activated even though the condition is just a few lines above with no changes. Below is a copy paste of that section -

boolean sorted = false;
System.out.println(toString());

while(sorted == false){
            System.out.println(toString());

The toStrings here are for testing purposes. The first one prints fine, but the second one never shows. Any idea why this code is not working like code should?

Last edited by RandomAccess at 22:01 Mar 15, 2018.
kknaur
Posts: 540
Posted 08:06 Mar 16, 2018 |

Taken out of context, it is not clear as to why this wouldn't work.  Generally speaking though, you don't normally say == false.  You would use the logical negation operator instead.

RandomAccess
Posts: 101
Posted 08:44 Mar 16, 2018 |

So != true instead?