Java is a 'pass by value' language, meaning that sending in a variable into a method, pointing the variable to a new object, does not effect the outer variable.
public void one() {
String s = "one";
two(s);
System.out.println(s);
}
public void two( String s ) {
s = "two";
}
Would write "one".
Is there a way to prevent this? Or what is the most common solution or pattern to actually change s
to "two" inside the method?