Article View: borland.public.jbuilder.java.language
Article #7413Re: changing reference in a method
From: dnoyeB
Date: Wed, 20 Jun 2001 21:24
Date: Wed, 20 Jun 2001 21:24
50 lines
2391 bytes
2391 bytes
You are new to java. I know because this was the same question I was asking
when I started in java from c++;
Its a hangover from the delete(obj) ideology;
However, since java does not do pointers, this functionality is out. This
is INDEED for safety. no such null pointers will be allowed to be created
by calling functions. If you got a null pointer, you know you made it null
yourself.
Class obj = new Class();
this obj variable CAN NOT be made null by any funtion call. it can only be
made null WITHIN its own scope. it works to eliminate havign to check if
your object isnull or not. You dont see many people in java catching null
pointer exceptions for this very reason...You will adapt.
"Ivan Trotter" <ivan@admiraluno.com> wrote in message
news:3b2ccfc1_1@dnews...
> Hi
>
> I have this source:
> public class MyObject{
> public void SomeMethod(Object anObject);
> ....
> anObject=null;
> }
>
>
>
> When I call this method, the anObject in params pass referenced, this
means
> that I can access the content of anObject in SomeMethod, after that I try
to
> change the reference: anObject = null, and only changes in the method,
but
> when steps over the method the reference become the same just before the
> method call.
>
> How can I assign null to the reference without returning some value in the
> method?
>
> I appretiate your help
>
> Ivan Trotter
>
>
Technical Details
Message-ID:
<3b327232$3_2@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnewsReferences:
<3b2ccfc1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,de239f43bd446264 X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-21 15:36:26 PST From: "dnoyeB" <lamont_gilbert @ rigidsoftware.com> Newsgroups: borland.public.jbuilder.java.language References: <3b2ccfc1_1@dnews> Subject: Re: changing reference in a method Date: Wed, 20 Jun 2001 17:24:30 -0400 Lines: 52 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 63.68.196.49 Message-ID: <3b327232$3_2@dnews> X-Trace: dnews 993161778 63.68.196.49 (21 Jun 2001 15:16:18 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-lei1.dfn.de!newsfeed00.sul.t-online.de!t-online.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews