package org.learn.callbyreference;
public class CallByReferenceTest {
String val = new String("Test");
public static void main(String[] args) {
CallByReferenceTest cTest = new CallByReferenceTest();
String s= new String("test this string");
cTest.changeString(s);
System.out.println(s);
System.out.println(cTest.val);
cTest.chagngeVal("Test1111");
System.out.println(cTest.val);
}
public void changeString(String s) {
s = "test 89898989";
}
public void chagngeVal(String s) {
val = "Test43323243242";
}
}
public class CallByReferenceTest {
String val = new String("Test");
public static void main(String[] args) {
CallByReferenceTest cTest = new CallByReferenceTest();
String s= new String("test this string");
cTest.changeString(s);
System.out.println(s);
System.out.println(cTest.val);
cTest.chagngeVal("Test1111");
System.out.println(cTest.val);
}
public void changeString(String s) {
s = "test 89898989";
}
public void chagngeVal(String s) {
val = "Test43323243242";
}
}