/**
* 交换int---by木木DR
*
@param a
* @param b
*/
public static void test(Integer a,Integer b) {
try {
Field field = Integer.class.getDeclaredField("value");
field.setAccessible(true);//去除private
//去除final影响
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
//交换
int temp = b;
field.set(b, a);
field.set(a, new Integer(temp));
} catch (Exception e) {
e.printStackTrace();
}
}