[java ee programming] Re: unclear new Object declaration

2009-03-19 Thread Lars Hermes

Hello,

to answer your question: NO it is not the same! In the first case you you only 
declare a variable of type Manager which has no reference to an object (i.e. 
null). In the second case you also create an object of type Manager and you 
immediately assign a reference to a newly created object of type Manager (i.e. 
new Manager()). If you set the reference of the variable manager to null 
afterwards, you throw the newly created object away and it will be cleared up 
by the GC. Maybe you'll take a look in the Standard Java programming course of 
Javapassion to gain a deeper understanding of OO.

Cheers
Lars 


I am trying to discern another programmer's code (good luck I know)

In a class that tests connectivity to a datasource, the first line
after the try { opening up is a statement that I am not clear on.

it is like this
import model.Manager;
public class DataSourceConnectionObject {
public static void main(String[] args) {
try {
Manager manager = null;

is this setting a new object of Manager named manager and setting it
to null ?
it this the same as if manager = new Manager and set manager =null on
second line?

just making sure its not doing something else...
thx


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Java 
EE (J2EE) Programming with Passion! group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~--~~~~--~~--~--~---



[java ee programming] Re: unclear new Object declaration

2009-03-18 Thread X. Yin

hi,

there's no   around null...

just

Manager mgr = null;

Thanks
XH

On Wed, Mar 18, 2009 at 12:31 PM, JAaronAnderson.com
acompetitorschalle...@gmail.com wrote:

 I am trying to discern another programmer's code (good luck I know)

 In a class that tests connectivity to a datasource, the first line
 after the try { opening up is a statement that I am not clear on.

 it is like this
 import model.Manager;
 public class DataSourceConnectionObject {
        public static void main(String[] args) {
        try {
        Manager manager = null;

 is this setting a new object of Manager named manager and setting it
 to null ?
 it this the same as if manager = new Manager and set manager =null on
 second line?

 just making sure its not doing something else...
 thx

 




-- 
Best Regards,
Xiaohang Yin
xiaohang@gmail.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Java 
EE (J2EE) Programming with Passion! group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to 
java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~--~~~~--~~--~--~---