Reputation: 4310
Any difference on these lines?
1. @Autowired
private MyClass obj;
2. @Autowired
private MyClass obj = null;
3. @Autowired
private MyClass obj = new MyClass();
Obviously, the third one is a bad practice.
Please explain.
Upvotes: 1
Views: 56
Reputation: 424983
No difference: The instance is injected by the container regardless what what you assign to it.
Option 1 is the best and most common style used.
Upvotes: 4