Sorry people, The e-mail was meant for someone else and not the JDJList...I sent the e-mail by mistake to JDJList.
Sorry for troubling you guys... Roger, Thanks for replying anyway. BTW, I knew the answer and the mail was meant as a question for a friend who is learning Java. Sorry again. Thanks. **************************************************************************** ********************************** "Those who don't know how to weep with their whole heart, don't know how to laugh either." **************************************************************************** ********************************** ----- Original Message ----- From: "Roger Glover" <[EMAIL PROTECTED]> To: "JDJList" <[EMAIL PROTECTED]> Sent: Sunday, October 06, 2002 11:48 AM Subject: [jdjlist] RE: a small question. unknown [mailto:[EMAIL PROTECTED]] wrote: > Can you lemme know the output of the following program and THE REASON ??? Calm down now. Take a few deep breaths. There now. It's a-a-a-a-all going to be alright. Are you going to be okay? Okay, now what seems to be the problem here? > import java.lang.*; > > public class Myself > { > public static void main(String args[]) > { > Myself x = new Myself(); > x.doIt(); > } > > void doIt() > { > int deepak = 10; > int returnInt = modifyIt(deepak); > System.out.println("Value is:: "+deepak); > System.out.println("returnString is:: "+returnInt); > } > > int modifyIt(int x) > { > x = 15; > return x; > } > } > > ========= > > I am getting output as 10, 15. Well then, it seems to me that the output (in full) should be: ------------------------------- Value is:: 10 returnString is:: 15 ------------------------------- As for the reason, that is quite simple. Java passes variables of primative type (like "int deepak") to method arguments (line "int x") by value. For more information, check out the "Language Basics" lesson of the "Learning the Java Language" trail of Sun's online Java tutorial, here: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html There. Better now? -- Roger ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________ ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________
