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 the point of oop?

1132


What is solid in oops?

1081


Why is object oriented programming so hard?

1054


What is the benefit of oop?

1020


just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.

6901


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

2106


What are the three parts of a simple empty class?

2019


What is difference between pop and oop?

1110


Is this job good for future? can do this job post grduate student?

2123


Advantage and disadvantage of routing in telecom sector

1269


What is the important feature of inheritance?

1088


What is and I oop mean?

1145


Why do we need oop?

1135


Whats is abstraction in oops?

1036


Why is static class not inherited?

1068