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前端其它相关文章!