public class Container {
private int value;
public Container(int value){
this.value=value;
}
public int getValue(){
return this.value;
}
public int sum(Container c){
return this.value+c.getValue();
}
public void main(){
Container c1=new Container(1);
Container c2=new Container(2);
System.out.println("sum: " + c1.getValue()+c2.getValue());
System.out.println("sum: " + c1.sum(c2));
}
}
when I am running this code I am getting the following results:
sum: 12
sum: 3
expected is:
sum: 3
sum: 3
Does anyone know why I am getting these results?