public class HelloWorld{
static class Sample {
private String n;
public Sample(String n){
this.n = n;
}
public String toString(){
return n;
}
}
public static void main(String []args){
Sample k = new Sample("A");
System.out.println(k);
stuff(k);
System.out.println(k);
}
public static void stuff(Sample k){
k = new Sample("B");
}
}
Why does this print AA instead of AB? I came across this from a video about C#, but apparantly java also has it.