Re: variable exchange



man4*.* wrote:
hello...
as a beginer in Java I've got a few workbooks for practice, so
here's one example.
-how to exchange content of 2 int variables x and y using only those 2
variables without using
any functions and any other variable?
temp=x;
x=y;
y=temp;
this would be easier...but they have to complicate.... :-)

Get a different book. You already know the simple, clear way of doing
the job. Why use a book that wants to waste your time on a very
specialized trick?

See http://www.caliberdt.com/tips/Apr2003.htm for a description of how
to swap without the temporary variable.

In addition to the limitations they describe, note that it temporarily
assigns one of the variables a value that is neither its old value nor
its new value. That may have implications in some multi-threaded code.

I've known the technique for about 20 years. I have yet to encounter a
situation in which I've needed to use it.

Patricia
.



Relevant Pages

  • Re: variable exchange
    ... as a beginer in Java I've got a few workbooks for practice, ... -how to exchange content of 2 int variables x and y using only those 2 ...
    (comp.lang.java.programmer)
  • variable exchange
    ... as a beginer in Java I've got a few workbooks for practice, ... -how to exchange content of 2 int variables x and y using only those 2 ...
    (comp.lang.java.programmer)
  • Re: variable exchange
    ... as a beginer in Java I've got a few workbooks for practice, ... -how to exchange content of 2 int variables x and y using only those 2 ...
    (comp.lang.java.programmer)
  • Re: excahnge best practice regarding SAN volume expansion
    ... I agree with John that it should be best practice to start with the size you ... seen any issues expanding LUNs using HP EVA 5000 or 8000 when Exchange was ... LUN on the fly with no downtime. ... When you expand the LUN, ...
    (microsoft.public.exchange.design)
  • Re: Internal MX record - needed?
    ... However as best practice you do want to have MX ... have third party MTAs that send to your Exchange as Martin suggested. ... Or if the servers have multiple NICS and only 1 is bound to SMTP etc.. ...
    (microsoft.public.exchange.admin)