×
Namespaces

Variants
Actions

Talk:How to swap variable values in Java ME using bitwise operations

From Nokia Developer Wiki
Jump to: navigation, search

i do seriously doubt that this code is any faster than swapping using a temporary variable... i think that variable assignement is at least as fast as a binary operation, if not faster. your version is making 3 binary xor, a version using temp variable will be using 3 assignement and so the 2 will execute as fast.

Ya it's right but this concept is useful for memory utilization. because the third variable increases the memory size little bit.--vkmunjpara 10:18, 19 September 2009 (UTC)
{{{width}}}
19 Sep
2009
Article Review by vkmunjpara (20090919)

Level: basic

This is a simple code but it uses a Bitwise XOR operator for swapping the values between two variables. So the extra third variable is not needed for swapping the values between variables.



 

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×