After the project is published, sometimes some minor changes are made, especially for some constants, such as the definition of some special accounts, third-party key values, when modified, I have been lazy before, because the project on the server, access speed is also limited, the replacement of the whole project is very troublesome, So it's just a substitute for a different class. This can lead to a very serious problem is that after the modification has no effect, because for public final static int .... Similar to this constant at compile time, the other class's bytecode has been written in the constant, rather than the constant reference, so just simply replace a class, compile this class is not right, and to all the classes are compiled once and replace, so can not be lazy AH!!!
In the Java project, will certainly encounter for the amount of processing, so for the amount of processing, the average person, think about it, with a float, double, not on its rounding and so on, this is not right, for the amount, we can use, but also the best use is BigDecimal, This class solves the problem of various data processing in Java, which corresponds to the decimal field in the database, so in future projects, the amount must be paid attention to.
BigDecimal number = Num.setscale (2,roundingmode.half_even);
Setscale is the method of setting the precision, and Roundingmode.half_even is called Banker rounding method, for the calculation of the amount above the use of such operations can reduce the algorithm above the amount above the loss, improve the project accuracy.
Note the small point after the project is published in Java, and the handling of the amount in Java