🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #12526

Re: java�еĴ�ֵ�ʹ�����

#12526
From: NUE
Date: Tue, 27 Jul 2004 03:33
57 lines
3419 bytes
�� �� xeon.bbs@bbs.nankai.edu.cn (98CS~��è~�����Կ�����) �Ĵ������ᵽ: ��
: ����û�����״�ֵ�ʹ����õ����
: ��ֵ��ʱ���ǽ�������һ��copy��Ȼ��copyѹջ��
: ������IJ���
: �����õ�ʱ����ֱ�ӽ����󣨾����ʵ����ָ�룩ѹջ��
: ���ݸ���ģ�������������?�����ڴ����õ�ʱ��

�㲢û�и�������ʲô�аѶ���ѹջ��ʲô�ֽ���copyһ��ѹջ�������DZ����ڱ�
������ʱ�����ջ��ģ��ٰ���ѹջ��hoho

�κ����ö���������ַ������ʵ�ֵġ�������ֱ�Ӱ�ջ�ڴ���ѹջ�������ԣ���һ��tij
�����ӣ�

//: appendixa:PassReferences.java
// Passing references around.
import com.bruceeckel.simpletest.*;

public class PassReferences {
  private static Test monitor = new Test();
  public static void f(PassReferences h) {
    System.out.println("h inside f(): " + h);
  }
  public static void main(String[] args) {
    PassReferences p = new PassReferences();
    System.out.println("p inside main(): " + p);
    f(p);
    monitor.expect(new String[] {
      "%% p inside main\\(\\): PassReferences@[a-z0-9]+",
      "%% h inside f\\(\\): PassReferences@[a-z0-9]+"
    });
  }
} ///:~

p inside main(): PassReferences@ad3ba4
h inside f(): PassReferences@ad3ba4

You can see that both p and h refer to the same object. This is far more 
efficient than duplicating a new PassReferences object just so that you can 
send an argument to a method. But it brings up an important issue.

 : �����ڲ��Զ�����޸Ķ�
��Ӱ�쵽�����?
: ������˵��ֻҪ���ݵ�ַ�ˣ����Ǵ����á���һ��c���Ե����ӣ�
: void printAddress( int p )

��������ҾͲ�˵ʲô��.. 

: {   
:     printf("%x", p );
: .................������ʡ�ԣ�

����Core JavaII�Ҷ��У�����Sun����д�ġ���ȫ�Ǹ��ѧ�߿������ŵ��顣���
��tij���ܱȡ��������java�����ô�����sun�Լ�Ҳ������͹������⣬��Ϊ����һ
ֱϣ��java����˵��������ԡ�����ʵ������ˡ��߼����Զ���������⡣
--
�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 219.206.224.14]
Technical Details
Message-ID: <4DO89a$B0S@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp-server.pubsub.com!netnews.sdu.edu.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,148db713ed371ece
X-Google-Attributes: gidf6cb0,public
X-Google-Language: Chinese,GB
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!nntp-server.pubsub.com!netnews.sdu.edu.cn!SJTU
From: nue.bbs@bbs.sjtu.edu.cn (NUE)
Newsgroups: cn.bbs.comp.lang.java
Subject: Re: java�еĴ�ֵ�ʹ�����
Date: 27 Jul 2004 03:33:10 GMT
Organization: ��ˮ˼Դ
Message-ID: <4DO89a$B0S@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: Java/M.1090898388.A
Lines: 57