how could change the method "change" that "java" print? I mean there is anyway to change local variable "x" for main method in method "change"? reflection can help or another way needed?how?
public static void main(String[] args) {
String x = new String("abc");
change(x);
System.out.println(x); //output = abc
}
public static void change(String x) {
x="java";
}
Aucun commentaire:
Enregistrer un commentaire