0

Why can my function not recognize my variable it that is made from my if/else function?

https://code.sololearn.com/cYWwdTx30296/?ref=app

22nd Mar 2020, 10:26 PM
David Nierman
David Nierman - avatar
4 Respostas
+ 8
You should declare variable first then use it in condition. Do like this String it = ""; if (x > 0) { it = "positive"; } else { it = "negative"; } return it;
22nd Mar 2020, 10:42 PM
A͢J
A͢J - avatar
+ 6
David Nierman It's printing positive. You did again wrong. Check my previous reply. Why did you declare static.
22nd Mar 2020, 11:01 PM
A͢J
A͢J - avatar
+ 2
AJ #Level 20 End Game ahh my bad, I accidentally declared it multiple times as a string.. I declared static to learn how to use static
22nd Mar 2020, 11:27 PM
David Nierman
David Nierman - avatar
+ 1
Thanks AJ #Level 20 End Game ! Follow up question..why will it not print positive ?
22nd Mar 2020, 10:51 PM
David Nierman
David Nierman - avatar