```
public class foo {

private int a[];
private int b;

public foo(){
    a = new int[] {1,2};
    b= 3;
}

public int[] getA(){
    return this.a;
}

public int getB(){
    return this.b;
}

```

I noticed that it's possible to change a value of A by accessing the object like this:

```
foo f = new foo();
f.getA()[0] = 5; // f.a[0] changes to 5

```

but it isn't possible to do something like:

```
f.getB = 5; // gives error
f.getA() = new int[]{2,3};  //gives error

```

can someone explain me how this works, and how to prevent the user from changing the value of an array cell?

Thanks in advance.