in C and JAVA, arguments are passed by value.
http://javadude.com/articles/passbyvalue.htm
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
http://www.yoda.arachsys.com/java/passing.html
http://www.javaranch.com/campfire/StoryPassBy.jsp
http://www.blogjava.net/qujinlong123/archive/2007/04/16/111060.html
http://www.cnblogs.com/seanps/archive/2009/02/11/1388077.html
example:
out:AB,B
析( 设存放有A的StringBuffer对象分配在地址为0x1的堆空间,存放有B的StringBuffer对象分配在地址为0x2的堆空间 ):
http://javadude.com/articles/passbyvalue.htm
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
http://www.yoda.arachsys.com/java/passing.html
http://www.javaranch.com/campfire/StoryPassBy.jsp
http://www.blogjava.net/qujinlong123/archive/2007/04/16/111060.html
http://www.cnblogs.com/seanps/archive/2009/02/11/1388077.html
example:
- public class TestStringBuffer {
- public static void main(String[] args) {
- StringBuffer a=new StringBuffer("A");
- StringBuffer b=new StringBuffer("B");
- method(a,b);
- System.out.println(a+","+b);
- }
- public static void method(StringBuffer x,StringBuffer y){
- x.append(y);
- y=x;
- }
- }
out:AB,B
析( 设存放有A的StringBuffer对象分配在地址为0x1的堆空间,存放有B的StringBuffer对象分配在地址为0x2的堆空间 ):