[Android Tips] 22. Available Java 7 Features in Android
2016-07-16 11:53 shaobin0604 阅读(268) 评论(0) 编辑 收藏 举报This only allows Java 7 language features, and you can hardly benefit from anything since a half of improvement also comes from the library. Features you could use are those which do not depend on the library:
- Diamond operator
<>
- String switch
- Multiple-catch
catch (Exc1 | Exc2 e)
- Underscore in number literals
1_234_567
- Binary literals
0b1110111
And these features cannot be used yet:
- The try-with-resources statement — because it requires the non-existing interface
java.lang.AutoCloseable
(this can be used publicly in 4.4+) - The
@SafeVarargs
annotation — becausejava.lang.SafeVarargs
does not exist