之所以要出这么一道题,是因为很多年前我在面试时被要求手写一个语义化版本的实现。
请实现一个Version.compare
。注意,在这个过程中,你可以在两种方法中二选一:
- 自己造一个轮子。
- 或者通过自己的搜索,使用别人已经造好的轮子(语义化版本这样通用的东西肯定有人实现过),但是要把别人的轮子适配到我们要求的
Version
中。
在提交Pull Request之前,你应当在本地确保所有代码已经编译通过,并且通过了测试(mvn clean test
)
注意!我们只允许你修改以下文件,对其他文件的修改会被拒绝:
完成题目有困难?不妨来看看写代码啦的相应课程吧!
回到写代码啦的题目,继续挑战!