Question: ```
public class Main {

    public static void main(String[] args){

        Class2 class2Object = new Class2();

        //class2Object
        //num1
        class2Object.setNumber(class2Object.number1, 1) ;

        class2Object.getNumber(class2Object.number1);
    }   

}

public class Class2 {
    public int number1;

    public void setNumber(int x, int value){
        x = value;

    }
    public void getNumber(int number){
        System.out.println("Class2, x = "+number);
    }
}

```

I have 2 class: Class2 and Main. I assign an instance variable to 1 in Main class. Why is class2Object.number1 not assign to a value of 1? Output is 0.

Answer: 
Your setter doesn't do anything:

```
public void setNumber(int x, int value){
    x = value;   // This just overwrites the value of x!
}

```

A setter should have only one parameter. You need to assign the received value to the member field:

```
// The field should be private.
private int number;

public void setNumber(int value){
    this.number = value;
}

```
In Java, primitive types (like int) are passed by value, not by reference.

So saying:

```
Class2 class2Object = new Class2();
class2Object.setNumber(class2Object.number1, 1) ;

```

passes `class2object.number1` by value, not by reference. So the parameter x in `setNumber` is a whole new int and is not pointing to the same location as `number1` in `class2object`. The method just overwrites the value of the new int x and does not modify the value pointed to by `number1`. 

In order to set the value it should be:

```
void setNumber(int newNumber) { this.number1 = newNumber; }

```