What's so confusing about this? The Java specification is VERY clear what's happening here; it's copying the reference of rset to the stack, and value() is modifying the object to which that reference points, which means the rset in the caller's state is affected. Pass by value.
Well-known, incredibly well specified. On Mon, Jun 24, 2013 at 1:15 PM, Deepak Sharma <stdeepa...@gmail.com> wrote: > Hello it seems so easy.. Isn't it?? > > Lets start.. > > we have in Java only pass by value not by reference.. > > *public class Testing * > *{* > * public static void main(String[] args)* > * {* > * int a=5;* > * System.out.println("values = " + a);* > * value(a);* > * System.out.println("values = " + a);* > * > * > * }* > * > * > * private static void value(int a)* > * {* > * a=10;* > * System.out.println("values = " + a);* > * * > * }* > *}* > * > * > output : > values = 5 > values = 10 > values = 5 > > Right?? > > now come to the point > > > *public class Testing * > *{* > * public static void main(String[] args)* > * {* > * ResultSet rset= conn.createStatement().executeQuesry("....");* > * > > * > * > value(rset); > * > * > > * > * > ** > // if here we try to access the rset, it says its close or something > else.. > * > * // Right?? if in Java there s o call by reference then > why local variable rset is not working here?? * > * }* > * > * > * private static void value(ResultSet a)* > * {* > * while(a.next())* > * {* > * ..* > * ..* > * ..* > * }* > * }* > *}* > > -- > You received this message because you are subscribed to the Google Groups > "Java Posse" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to javaposse+unsubscr...@googlegroups.com. > To post to this group, send email to javaposse@googlegroups.com. > Visit this group at http://groups.google.com/group/javaposse. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Joseph B. Ottinger http://enigmastation.com *Memento mori.* -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To unsubscribe from this group and stop receiving emails from it, send an email to javaposse+unsubscr...@googlegroups.com. To post to this group, send email to javaposse@googlegroups.com. Visit this group at http://groups.google.com/group/javaposse. For more options, visit https://groups.google.com/groups/opt_out.