how to swap to variables without using thrid variable in java?
Answer Posted / igor polivanyi
It’s pretty simple:
int a = 12;
int b = 34;
a = a + b;
b = a - b;
a = a - b;
And for real cowboys, it could be simplified further:
a -= (b = (a += b) - b);
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What is oops in simple words?
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE
METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN
A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS? Prepare me a program for the animation of train What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems? What is object and example? What is the important feature of inheritance? What is the oops and benefits of oops programming? What is a superclass in oop? What is the purpose of enum? What is oops and why we use oops? Can destructor be overloaded? Can enum be null? String = "C++ is an object oriented programming language.An
imp feature of oops is classes and objects".Write a pgm to
count the repeated words from this scenario? How to call a non virtual function in the derived class by
using base class pointer