#I am newbie in Java. I have a doubt in below code.

1 messages · Page 1 of 1 (latest)

long helm
#

We have manipulated the value of a variable which was declared outside If statement. According to me if its value is changed inside the block of If statement , it should not have changed its value for the rest of code. Please advise where i am wrong
I get 0 in the end.

rustic kiteBOT
#

This post has been reserved for your question.

Hey @long helm! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

foggy parrot
#

That would make if/else constructs fairly useless

long helm
#

So if i would have modified the value in a method instead of conditional statement then it would have been a correct scenario?

foggy parrot
#

This is a bit too abstract. Ask a more direct question

long helm
#

If i would have declared a method and modified the value highScore (initial 50)
let’s say highscore += 100; and print it outside the method then it would have become 150?

foggy parrot
#

Too ambiguous. Just try and be faultless when you tell a theory please. (Also that sounds like the sort of things you could just try)

long helm
#

I understood your point. I was just trying to get double sure. I will try. Thanks a lot for help!

rustic kiteBOT