Forums Register Login

While Statement

+Pie Number of slices to send: Send
i want to obtain a value and assign it to b in a while statement and i also want to test to see if B is null in the same statement, Please how do i do this


I tried but it resulted in errors

+Pie Number of slices to send: Send
Just add some parentheses to clarify the order:
+Pie Number of slices to send: Send
!= has precedence over =, so if you write it without parentheses the compiler will see this:

Now seeing as b is not a boolean, this will fail.

If you add parentheses as Jim has done, the compiler will have no problems anymore; it will first use the assignment to b, and only then compare the value of b to null.
+Pie Number of slices to send: Send
thanks
Does this tiny ad smell okay to you?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 659 times.
Similar Threads
Trouble Displaying all the data
if and while statements
unreachable statement
Resource closing in JDBC
Checking variable initialization...
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:02:57.