Swapping two variables in One Line

Hi friends,

Recently i was there in a situation where in i needed to swap the values rather using the traditional way.

Following is the small java program which will give you the idea:

If you don’t like bitwise operations u can use following program

 

Feel free to comment if you have any doubts and share if like. 🙂

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s