Java initialization method: Class, container, java initialization container
Java initialization method: Class, container
Initialization class (non-final): In the DefaultActionMapper class of Struts2, public defaactionactionmapper () {prefixTrie = new PrefixTrie () {put (METHOD_PREFIX, new ParameterAction () {public void execute (String key, ActionMapping mapping) {if (allowdynamicmethodcils) {mapping. setMethod (key. substring (METHOD_PREFIX.length ()));}}});//.... }};}
Put is the PrefixTrie method: public void put (String prefix, Object value );
Initialize the container: the original method in the Collection framework (collections, such as list, map, set, etc.): Set <String> myset = new HashSet <String> (); myset. add ("aa"); myset. add ("bb"); myset. add ("cc"); myset. add ("dd"); domethod (myset); static initial method: private static final Set <String> myset = new HashSet <String> (); static {myset. add ("aa"); myset. add ("bb"); myset. add ("cc"); myset. add ("dd");} a new set is created and initialized using double-brace syntax: private static final Set <String> myset = new HashSet <String> () {add ("aa"); add ("bb"); add ("cc "); add ("dd") ;}}; doMethod (new HashSet <String> () {add ("aa"); add ("bb "); add ("cc"); add ("dd ");}});
The first layer of ArcActually,
Internal Anonymous class(Anonymous Inner Class );
Layer 2 arcIs actually
Instance initialization Block(Instance initializer block), which is executed during internal Anonymous class construction.