The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

swapping in Java

Posted by karthik on January 22, 2001 at 7:49 AM

hi,
can anyone tell me how to swap values in Java? I thought java is
pass by value, so it's not possible but someone told me that there's a solution.

Integer a = new Integer(1);
Integer a = new Integer(2);
swap(a,b);

swap(Integer m, Integer n){
...??
}

now a --> 2
b -->1

thanks in advance
karthik.



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us