Java is Pass-by-Value Java都是值传递

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: 
Java代码   收藏代码
  1. public class TestStringBuffer {    
  2.     
  3.     public static void main(String[] args) {    
  4.         
  5.         StringBuffer a=new StringBuffer("A");    
  6.         StringBuffer b=new StringBuffer("B");    
  7.         method(a,b);    
  8.         System.out.println(a+","+b);    
  9.     }    
  10.     public static void method(StringBuffer x,StringBuffer y){           
  11.         x.append(y);     
  12.         y=x;    
  13.     }    
  14. }    

out:AB,B 
析( 设存放有A的StringBuffer对象分配在地址为0x1的堆空间,存放有B的StringBuffer对象分配在地址为0x2的堆空间 ): 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值