Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

if's

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why somehow during my 4th If statement that my Boolean 'up' gets changed to False. I don't understand if 'up' is now changed to False that 'i' does not decrement. I figure that if the If does not satisfy the condition it should simply be skipped. But that does not seem to be the case.


CONSOLE RESULTS:
Value of i = 0
Value of up-1 = true
Value of up-2 = true
Value of up-3 = true
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 1
Value of up-1 = false
Value of up-2 = false
Value of up-3 = false
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 2
Value of up-1 = false
Value of up-2 = false
Value of up-3 = false
TRUE CONDITION
Value of up-4 = true
Value of up-5 = false
Value of i = 3
...etcetera....

Thanks

 
author & internet detective
Posts: 40709
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is something that is tricky for those new to Java


This assigns true to up and checks if up is true. Which it always is.


This checks if up is true.

You want the second one.
 
George Willis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Grrrr! I knew that but noobed it nonetheless.
Thanks!
 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
What do you mean by 'noobed'?
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's one reason why I think it's preferable to use if(up) and if(!up), instead of if(up == true) and if(up == false).
 
Marshal
Posts: 73732
332
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never try writing == false or == true.
Always write if (up)... or if (!up)...
That should prevent that particular error.
 
Jeanne Boyarsky
author & internet detective
Posts: 40709
827
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Ngom wrote:Hi George,
What do you mean by 'noobed'?


noob is slang for someone new to something. It is a synonym for newbie.

Noobed is not something I had heard before, but I can infer it to mean to make a mistake that a new person would make.
 
Ranch Hand
Posts: 116
2
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Never try writing == false or == true.
Always write if (up)... or if (!up)...
That should prevent that particular error.



This is something I need to keep in mind for myself also. I tend to write == true or == false.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


noob is slang for someone new to something. It is a synonym for newbie.

Noobed is not something I had heard before, but I can infer it to mean to make a mistake that a new person would make.


Thank you Jeanne. I now get the meaning.
 
Campbell Ritchie
Marshal
Posts: 73732
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which case it would be best to avoid noob as a verb in future, please. One reason for requiring real words is that they cause confusion to non‑native English speakers.
 
George Willis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the rules mistake.
And, thank you all for the further discussion and advice.
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic