Update Test.java and MathGame.java #2643
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
对于/math-game/src/main/java/demo/MathGame.java,做了以下几处改动:
1.限制产生的随机最小值为2,防止后步比较时出现number<i的错误
2.将StringBuffer替换为StringBuilder以提高性能和线程安全性
对于/testcase/src/main/java/com/alibaba/arthas/Test.java,做了以下几点改动:
1.Map的初始化指定了具体的类型参数,减少类型转换时出错的可能性
2.将p初始化为非空的默认值,因其在System.out.println(p)时可能存在空指针异常的风险
3.修改随机数的产生逻辑,防止性能上的损耗
4.增加用户友好的异常退出机制