public class Test {
private Result result;
public Test(Result res){
this.result = res;
}
public void alter(){
this.result = Result.FAIL;
}
}
public enum Result{ PASS, FAIL, MORE};
public Result myResult = Result.PASS;
Test test = new Test(myResult);
test.alter();
In the above example, how would I modify the variable myResult
inside the alter
method? Since Java is pass by value, the example simply assigns its value to this.result
.