How do I change two variables (of different types) on the same line in Java?
-
For instance, I want to combine the following two statements so they are on the same line in an if statement: ref = i b = true ref is an integer and b is a boolean. How do I change them at the same time?
-
Answer:
Quite a strange question. Is that what you mean? ... ref = i; b = true; ... and is equivalent to: ... ref = i; b = true; ... and has no impact on performance. The 2nd way is more readable.
SKKKKKAF... at Yahoo! Answers Visit the source
Other answers
You can separate the statements by a semi-colon and enclose that in curly braces, on the same line, i.e.: { ref = i; b = true; }
alex
That's generally not something that people want to do. In addition to the fact that the computer most likely isn't going to do them at the same time anyways, you would be mucking up your code, and making it less readable for other developers to maintain. If you could give us some insight into WHY you want to do this, someone might be of more help in addressing your issue.
thedude81321
Booleans may not be cast into any other type of variable nor may any other variable be cast into a boolean.
just_me ♦
Related Q & A:
- How do I compare two tables with the same column definitions in different schemas?Best solution by Database Administrators
- How do I change the cursor from a blinking black block to a blinking line?Best solution by Server Fault
- How do I bridge two different amps together?Best solution by ecoustics.com
- How do I change my my Yahoo ID to a different name, but still have the same account?Best solution by Yahoo! Answers
- How do I change my Signature Line on my emails?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.