Dead store to local variable in findbugs

To report this kind of problem, in simple terms is to define an unused object.

The example code is as follows:

Map<String,String>  A = new HashMap();
A=user1.getMap();
A=user2.getMap();
A=user3.getMap();

The above code obviously does not use the newly created HashMap at the beginning, but constantly reassigns the A variable through the User object, so there is no need to create this HashMap object.

The code is optimized as follows:

Map<String,String>  A;
A=user1.getMap();
A=user2.getMap();
A=user3.getMap();

Guess you like

Origin blog.csdn.net/weixin_38106322/article/details/111241896