How to manage multiple versions of same class file for different SDK targets?

This is for an Android application but I'm broadening the question to Java as I don't know how this is usually implemented. Assuming you have a project that targets a specific SDK version. A new release of the SDK is backward incompatible and requires changing three lines in one class. How is this managed in Java without duplicating any code(or by duplicating the least amount)? I don't want to create two projects for only 3 lines that are different. What I'm trying to achieve in the end is a single executable that'll work for both versions. In C/C++, you'd have a `#define` based on the version. How do I achieve the same thing in Java? **Edit**: after reading the comments about the #define, I realized there were two issues I was merging into one: - So first issue is, how do I not duplicate code ? What construct is there that is the equivalent of a `#define` in C. - The second one is: is it possible to bundle everything in the same executable? (this is less of a concern as the first one).

以上就是How to manage multiple versions of same class file for different SDK targets?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏