Well,
if you use varargs syntax you can do it like this:
void foo( int .. A ) {
}
int a = 0;
foo( a );
Will put A automagically into an array. If you cannot use varargs (<1.5)
then you gotta do:
void foo( int [] A ) {
}
int a = 0;
foo ( new int [] {a} );
Greetings,
Jan
> Hi,
>
[quoted text clipped - 15 lines]
>
> Sun

Signature
__________________________________________________________
insOMnia - We never sleep...
http://www.insomnia-hq.de
hyena - 23 Nov 2006 13:02 GMT
Thanks Jan. The second one is the answer to me. I am using 1.4.2.
> Well,
>
[quoted text clipped - 40 lines]
>>
>> Sun
Thomas Schodt - 23 Nov 2006 13:48 GMT
> void foo( int [] A ) {
>
[quoted text clipped - 3 lines]
>
> foo ( new int [] {a} );
However, changing A[0] inside foo() has no effect on a.
public class Pass {
public static void main(String[] arg) {
new Pass().run();
}
void run() {
int a = 5;
foo(new int[]{a});
System.out.println(a);
}
void foo(int[] A) {
A[0] = 7;
}
}
Andreas Leitgeb - 23 Nov 2006 17:14 GMT
>> void foo( int [] A ) {
>> }
>> int a = 0;
>> foo ( new int [] {a} );
>
> However, changing A[0] inside foo() has no effect on a.
to "fix" that:
int a = 0;
int[] ia = {a};
foo (ia);
a=ia[0];