...
In this noncompliant code example, multiple threads can invoke the setValues()
method to set the a
and b
fields. Because this class does not test for integer overflow, a user of the Adder
class must ensure that the arguments to the setValues()
method can be added without overflow. (For more information, see guideline NUM00-J. Ensure that integer operations do not result in Detect or prevent integer overflow.)
Code Block | ||
---|---|---|
| ||
final class Adder { private int a; private int b; public int getSum() { return a + b; } public void setValues(int a, int b) { this.a = a; this.b = b; } } |
...