java8

What is new in Java 8?

Java Programming Language

  1. Lambda expressions enable you to treat functionality as a method argument, or code as data. Lambda expressions let you express instances of single-method interfaces (referred to as functional interfaces) more compactly.
  2. Method References provide easy-to-read lambda expressions for methods that already have a name.
  3. Default methods enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions of those interfaces.
    1. Java - default methods in Interfaces
  4. Repeating Annotations provide the ability to apply the same annotation type more than once to the same declaration or type use.
  5. Type Annotations provide the ability to apply an annotation anywhere a type is used, not just on a declaration. Used with a pluggable type system, this feature enables improved type checking of your code.
  6. Improved type inference.
  7. Method parameter reflection.

Collections

  1. Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. The Stream API is integrated into the Collections API, which enables bulk operations on collections, such as sequential or parallel map-reduce transformations.
  2. Performance Improvement for HashMaps with Key Collisions
Stream API Abstract layer that provides pipeline processing of the data. a special iterator class that allows processing object collections in a functional manner

java.lang and java.util Packages

  1. Parallel Array Sorting
  2. Standard Encoding and Decoding Base64
  3. Unsigned Arithmetic Support

JDBC

KNOWLEDGE GAP - LEARN MORE

What does this mean?

  1. The JDBC-ODBC Bridge has been removed.
  2. JDBC 4.2 introduces new features.

Concurrency

Java 8 Concurrency API improvements

Date-Time Package -

java8 - Date-Time package

Miscellaneous

Optional

Java Optional Class

Nashorn JavaScript Engine

a high-performance Java-based engine integrated to JDK used to evaluate and execute JavaScript code

What programming paradigms does Java 8 support?

  1. Object-oriented programming language.
  2. Functional programming language.
  3. Procedural programming language.
  4. Logic programming language

What are the significant advantages of Java 8?

  1. Compact, readable, and reusable code.
  2. Less boilerplate code.
  3. Parallel operations and execution.
  4. Can be ported across operating systems.
  5. High stability.
  6. Stable environment.
  7. Adequate support

What is MetaSpace? How does it differ from PermGen?

PremGen : MetaData information of classes was stored in PremGen (Permanent-Generation) memory type before Java 8. PremGen is fixed in size and cannot be dynamically resized. It was a contiguous Java Heap Memory.

MetaSpace : Java 8 stores the MetaData of classes in native memory called ‘MetaSpace’. It is not a contiguous Heap Memory and hence can be grown dynamically which helps to overcome the size constraints. This improves the garbage collection, auto-tuning, and de-allocation of metadata.

KNOWLEDGE GAP - LEARN MORE https://www.baeldung.com/java-permgen-metaspace#:~:text=Simply%20put%2C%20Metaspace%20is%20a,region%20grows%20automatically%20by%20default.

Static methods in Interfaces

Java - static methods in Interfaces

What is type inference?

Type inference is available even in earlier versions of Java. It is used to infer the type of argument by the compiler at the compile time by looking at method invocation and corresponding declaration.

Streams API

Java Streams Api

Functional Interfaces, Lambda Expressions and Method References

Functional Interfaces, Lambda Expressions and Method References

KNOWLEDGE GAP - LEARN MORE

https://www.baeldung.com/java-8-interview-questions


Links to this note