1 class TestClass {
2 public void method1 (int[] a, int[] b)
3 {
4 a = b;
5 a[0] = 10;
6 System.out.println("a[0] = " + a[0]);
7 System.out.println("b[0] = " + b[0]);
8 }
9
10 public void method2 (int x, int y)
11 {
12 x = y;
13 x = 4;
14 System.out.println("x = " + x);
15 System.out.println("y = " + y);
16 }
17
18 public static void main(String [] args)
19 {
20 TestClass test = new TestClass();
21 int x = 2; int y = 3;
22 int[] a = new int[] {5,6,5,6};
23 int[] b = new int[] {1,8,1,8};
24
25 test.method1(a, b);
26 test.method2(x, y);
27
28 System.out.println("x = "+x+"; y = "+y+"; a[0] = "+a[0]);
29 }
30 }
Call by value/reference sorusu. Main method çağırılırsa hangi değer gelir diye sorulmuş.
2 public void method1 (int[] a, int[] b)
3 {
4 a = b;
5 a[0] = 10;
6 System.out.println("a[0] = " + a[0]);
7 System.out.println("b[0] = " + b[0]);
8 }
9
10 public void method2 (int x, int y)
11 {
12 x = y;
13 x = 4;
14 System.out.println("x = " + x);
15 System.out.println("y = " + y);
16 }
17
18 public static void main(String [] args)
19 {
20 TestClass test = new TestClass();
21 int x = 2; int y = 3;
22 int[] a = new int[] {5,6,5,6};
23 int[] b = new int[] {1,8,1,8};
24
25 test.method1(a, b);
26 test.method2(x, y);
27
28 System.out.println("x = "+x+"; y = "+y+"; a[0] = "+a[0]);
29 }
30 }
Call by value/reference sorusu. Main method çağırılırsa hangi değer gelir diye sorulmuş.

e buraya soracağına çalıştırsana kodu. bak burada ben çalıştırdım:
ideone.com
bilmen gereken java'da primitive type'ların pass by value, geri kalan herşeyin pass by reference olduğu. Primitive tipler
docs.oracle.com
samfisher


o ne güzel siteymiş öyle. Eclips'de denedim, eksik librarileri de ekledim ama tuhaf tuhaf hatalar verince bilene danışayım dedim.
çok ama çok teşekkürler
beholderrulez

1