The current implementation is inefficient because every LootBox instance creates a new instance of the random number generator, which is an expensive operation; instead, make the instance of the random number generator static, so that it is shared by all instances of the class, and there will be only one created.
Note: This will work fine in the current code by just adding the 'static' keyword to the declaration of the variable, but if the random number generator is ever parameterized, you will want to create an 'init()' function to rebuild the random number generator using the parameters for that run, and then call this init() method during the builder method of the JLootBoxBuilder class.
The current implementation is inefficient because every LootBox instance creates a new instance of the random number generator, which is an expensive operation; instead, make the instance of the random number generator static, so that it is shared by all instances of the class, and there will be only one created.
Note: This will work fine in the current code by just adding the 'static' keyword to the declaration of the variable, but if the random number generator is ever parameterized, you will want to create an 'init()' function to rebuild the random number generator using the parameters for that run, and then call this init() method during the builder method of the JLootBoxBuilder class.