It depends on the context. If this class could be replaced with only one static int, then I do not see the need to create an inner class.
On the other hand, this code will allow the parent objects of the class to exchange a reference to mutable int (using java.lang.Integer would be impossible because it is immutable).
The general advice / practice / template in this case is Keep It Simple, and you won’t need it - if you don’t do this, you need certain behavior, do not make the code more complicated than it is absolutely necessary.
So, if the question: “It’s good practice to create an inner class for simple functionality, when it could be resolved in a simpler way,” then the answer will be NO .. p>
surfen
source share