Re: I lost the point: purpose of putting objects to null?
From: EricF (efriedNoSpam_at_yahoo.com)
Date: 10/25/04
- Previous message: Hal Rosser: "Re: Problem starting out with Java . . ."
- In reply to: Dan Nuttle: "Re: I lost the point: purpose of putting objects to null?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 25 Oct 2004 02:39:50 GMT
Actually you do gain something in a server or long running application by
setting objects to null. These objects can be garbage collected.
Eric
In article <62Ped.6249$5i5.2463@newsread2.news.atl.earthlink.net>, "Dan
Nuttle" <d_nuttle@hotmail.com> wrote:
>You don't technically gain anything by doing this. However, I'm a believer
>in declaring variables whenever possible at the top of a class or method.
>Instead of having variable declarations scattered all over. So I tend to
>have lots of lines like
>
>MyObject _o = null;
>
>at the top of a class or method. That way, when I see a variable and I
>don't know what type it is, I can look at the top of the class or method and
>quickly find out. You can just declare the variable without setting it to
>null, but then your class might not compile unless every single method that
>uses the variable makes sure it's been initialized.
>
>Some coding philosophies consider it very bad form to declare and
>instantiate a variable at the same time, in the body of a method, like this:
>
>public void myMethod()
>{
>
>//Some code here
>String myString = "ABC";
>
>}
>
>But this is more of a philosophy than a technology issue.
>
>
>"Dado" <dzupan@mail.inet.hr> wrote in message
>news:ciu803$3aq$1@sunce.iskon.hr...
>> I lost the point:
>> What is purpose of putting objects to null:
>>
>> If I make a class, JFrame for example, with button which start connection
>> dialog, which is class with connection and statement Object.
>> And every time I click the button first I put :
>> dialog = null
>> dialog = new dialog()
>>
>> What is purpose to put dialog = null when all its objects are stay
>non-null?
>>
>>
>>
>>
>>
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.725 / Virus Database: 480 - Release Date: 19.7.2004
>>
>>
>
>
- Previous message: Hal Rosser: "Re: Problem starting out with Java . . ."
- In reply to: Dan Nuttle: "Re: I lost the point: purpose of putting objects to null?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]