Topic: 菜鸟求助~~~关于对象的传递问题~~

  Print this page

1.菜鸟求助~~~关于对象的传递问题~~ Copy to clipboard
Posted by: naughty009
Posted on: 2005-07-12 23:48

例如:
class A{.........}

class B{
public void do(A a){.......}
}

我想知道这样传递对象有何好处呀?
因为见到很多程序都是这样的~~~~~可否举个例来说明下~~高手们~~~感谢ING~

2.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: naughty009] Copy to clipboard
Posted by: why
Posted on: 2005-07-12 23:53

不如先想想那些程序不这样又會怎様
這麼才易比較,說出好处來

3.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: naughty009] Copy to clipboard
Posted by: mesocool
Posted on: 2005-07-14 13:20

这样好像不是传递吧..

4.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: mesocool] Copy to clipboard
Posted by: ww1ww1
Posted on: 2005-07-14 21:12

mesocool wrote:
这样好像不是传递吧..


可以举个对象传递的例子吗?谢谢

5.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: ww1ww1] Copy to clipboard
Posted by: mesocool
Posted on: 2005-07-15 09:19

ww1ww1 wrote:
可以举个对象传递的例子吗?谢谢


看具体目的是啥了..

6.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: mesocool] Copy to clipboard
Posted by: njluz
Posted on: 2005-07-16 13:02

mesocool wrote:
看具体目的是啥了..


同意楼上看法,要看具体设计需要,
举几个例子:
1.Collection中的add,remove方法
2.Visitor Pattern中Visitor 等等

7.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: naughty009] Copy to clipboard
Posted by: 22750124
Posted on: 2005-07-17 19:36

。。。这不是传递,是引用
C++中你就应该学了

8.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: naughty009] Copy to clipboard
Posted by: baidongli
Posted on: 2005-07-19 09:22

java中只有passed by value ...

9.Re:菜鸟求助~~~关于对象的传递问题~~ [Re: naughty009] Copy to clipboard
Posted by: hlnccc
Posted on: 2005-07-20 14:18

能实现就行了,讨论这种字面上的东西没多大用处


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923