Android uses a standard Java compiler to compile your source code into regular bytecodes and then translates those bytecodes into instructions to execute. Therefore, nearly the entire Java language is supported, not just a small subset. By using the stock compiler and bytecodes, you often don’t even need to have the source code for libraries that you want to use in your applications.
Android Studio supports code compatible with Java Standard Edition 6 or earlier, with optional additions from Java 7. At present, none of the Java 8 features are available.
To enable Java 7 language features, you need to add these lines to your gradle build file: