public class add {
private final int NUMBER;
public add(int x){ NUMBER = x;}
}
public class Final {
public static void main(String[] args) {
add addingTen = new add(10);
add addingEleven = new add(11);
System.out.println(addingTen);
System.out.println(addingEleven);
System.out.println(addingTen);
}
}
OUTPUT : sum = 10 sum = 11 sum = 10 //why does the NUMBER variable still change although i declared it as final?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
It does not change,
addingTen
andaddingEleven
are different objects each with their own initial value.