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" <dz****@mail.inet.hr> wrote in message
news:ci**********@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