With spring annotation @Autowired annotation, we can bind the bean automatically by type.
@Autowired
If there are several beans with the same type, how to decide which one to autowire?
By default, the bean is in singleton pattern. That is, in the spring application context, there will be only instance.
When to use? we have many parameters in a class.
Some other methods(not good options)
I only know one singleton creation method before, the factory method. The book list three methods and suggusts that the third method-Enum method is the best one. What a supurise :)
When we create a new class, most time we need to override the equal method. The book lists 5 rules.
x.equals(x) == true
When overriding the equalmethod, always override the hashCode()method, or the HashSet, HashMap... methods would fail.
equal
hashCode()
HashSet, HashMap...