Object as Reference not working..Please help..!!!

public class GG{
public static void main(String[] args) {
Integer i = new Integer(10);
System.out.println("Before Call:"+i);
change(i);
System.out.println("After Call:"+i);
public static void change(Integer x){
x=20;
Here the output is coming
Before Call:10
After Call:10
I am confused when i am passing an object in a function then why the value is not changed as objects are passed by reference??

Java is pass-by-value. Recommended reading:
[http://www.javaranch.com/campfire/StoryCups.jsp]
[http://www.javaranch.com/campfire/StoryPassBy.jsp]
This topic has been done to death too many times already. I'm moving this thread to New to Java and locking this it. Jasvinder.Singh, please confine your questions to the New to Java forum until such time as you can regard yourself as a Java Programmer.
db

Similar Messages

Maybe you are looking for

  • A Personal Assessment And A Tip Of The Hat

    Hosts and Long Time Responders, My first visit to the Discussion Boards was on 7/9/08 or 7/10/08. I came for some advice and was very happy to have finally found a place where people were willing to share what they know about all things Mac and also,

  • Mail and Address Book Issues in 10.4.5

    Hello: I recently updated to 10.4.5 and have some issues with mail and address book. 1. MAIL: All the mail on my machine has been "reformatted" for lack of a better term. Each line in a paragraph is about 1.5" above the next. This is the same for all

  • Weblogic server 8.1 sp5 connection to MQ V 7.1

    Hi, We are using Weblogic 8.1 sp5 to connect to Websphere MQ v 5.3 using the "Foreign JMS Server" connectivity of Weblogic. Websphere MQ Qmgr is being accessed in ".bindings" mode. we have configured an XA Queue connection factories and queues in the

  • MD73 - not displaying customer order assignment

    Hi, I am having 2 materials - both set up with planning strategy 40. For one material, Customer order assignment is displayed in MD73 but for other material it is not displaying. MRP-1 to MRP-4 viewa are same for both parts. What else shall I need to

  • Project code compulsion

    Dear All, I want to make selection of project code mandatory in every document ,can it be possible?