+ 1
What is the difference?
A a; A a=new A() ;
4 Answers
+ 8
A a; - just declare object
A a = new A(); - declare and initialize object at the same time
+ 7
A a; // you declare a variable a of type A with nothing in it
A a = new A() ; // you declare a variable of type A and initialize it with a new Object of type A.
a.dosomething() in the first case would throw a nullpointer exception and the second would execute the method dosomething
+ 3
A a; declare object "null"
A a = new A(); declare and initialize object "allocated memory"
+ 2
A a creates the variable new A(); creates the object