Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What is oops in simple words?

1035


i=20;k=0; for(j=1;k-i;k+=j<10?4:3) { cout<

1813


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?

2150


Prepare me a program for the animation of train

2414


What are different types of JVM's? for example we use dalvik jvm for android then what about the remaining operating systems?

2083


What is object and example?

1116


What is the important feature of inheritance?

1072


What is the oops and benefits of oops programming?

928


What is a superclass in oop?

1112


What is the purpose of enum?

967


What is oops and why we use oops?

995


Can destructor be overloaded?

979


Can enum be null?

965


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?

2335


How to call a non virtual function in the derived class by using base class pointer

6427