[1777] in java-interest

home help back first fref pref prev next nref lref last post

Re: A few queries...

daemon@ATHENA.MIT.EDU (Jonathan Payne)
Sat Sep 16 22:38:57 1995

Date: Fri, 15 Sep 1995 13:29:26 -0700
From: jpayne@starwave.com (Jonathan Payne)
To: aw@bae.bellcore.com
Cc: java-interest@java.sun.com
In-Reply-To: <9509151900.AA17921@jello> (message from Andrew Wason on Fri, 15 Sep 95 15:00:27 -0400)

All objects are pointers, and the pointer values are passed by value.


> Date: Fri, 15 Sep 95 15:00:27 -0400
> From: Andrew Wason <aw@bae.bellcore.com>
> Sender: owner-java-interest@java.sun.com
> Precedence: bulk
> X-Info: To unsubscribe, send 'unsubscribe' to java-interest-request@java.sun.com
> Content-Type: text
> Content-Length: 1116
> 
> Llew Mason <mason_l@ee.uwa.edu.au>  writes:
> > 
> >   As far as I could tell this wasn't discussed in any of the provided =
> > documention.  Java currently passes class arguments by non-const =
> > reference.  
> 
> It looks like method arguments are passed by value.
> 
> The following prints:
> 
> o=java/lang/Object[]i=10
> o=java/lang/Object[]i=10
> 
> If the arguments were passed by reference, the locals in main()
> would have been modified by the call to foo.
> 
> class Ref {
>     static void foo(int i, Object o) {
>         i = 7;
>         o = new Object();
>     }
>     public static void main(String argv[]) {
>         int i = 10;
>         Object o = new Object();
>         System.out.println("o=" + o + "i=" + i);
>         foo(i, o);
>         System.out.println("o=" + o + "i=" + i);
>     }
> }
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post