Java 16 New Stream Methods – toList(), mapMulti(), ofNullable()

Java 16 introduced several new methods in the Stream API, enhancing the functionality and flexibility of streams in Java. These additions make it easier to work with streams by providing more options for processing, transforming, and collecting data. The new methods in Java 16 include Stream.toList(), Stream.mapMulti(), and Stream.ofNullable(). Key Points: Stream.toList(): Provides a convenient …

Java 16 New Stream Methods – toList(), mapMulti(), ofNullable() Read More »

Pattern Matching for instanceof in Java

Introduction Java 16 introduced pattern matching for instanceof, a feature that simplifies the use of the instanceof operator and type casting. This enhancement allows developers to perform type checks and casts more concisely and safely. With pattern matching, the instanceof operator not only checks the type but also casts the variable to the desired type …

Pattern Matching for instanceof in Java Read More »

Java 15 New String and CharSequence Methods

Java 15 introduced several new methods in the String and CharSequence classes to enhance the manipulation of strings and character sequences. These methods provide more convenient ways to perform common operations and improve code readability and efficiency. Key Points: Improved String Manipulation: New methods offer more straightforward and efficient ways to work with strings. Convenience: …

Java 15 New String and CharSequence Methods Read More »

Helpful NullPointerExceptions in Java

Introduction Java 14 introduced a new feature known as Helpful NullPointerExceptions that aims to improve debugging by providing more informative error messages when a NullPointerException occurs. This feature helps developers quickly identify the root cause of NullPointerExceptions by specifying which part of the expression was null, making it easier to fix bugs in Java applications. …

Helpful NullPointerExceptions in Java Read More »

Java 12: Compact Number Formatting

Introduction Java 12 introduced compact number formatting as part of the java.text.NumberFormat class, allowing developers to format numbers in a concise and human-readable way. This feature is particularly useful for applications that need to display large numbers in a compact form, such as financial or statistical data. Compact number formatting is supported through the NumberFormat.Style …

Java 12: Compact Number Formatting Read More »

Java 12 New String Methods

Java 12 introduced new methods to the String class that enhance string manipulation capabilities. These methods provide more flexibility and convenience for developers working with strings, offering solutions for common string-related tasks such as alignment and transformation. New String Methods in Java 12 1. indent(int n) The indent() method was enhanced in Java 12. It …

Java 12 New String Methods Read More »

Files.readString() and Files.writeString() in Java

Introduction Java 11 introduced two new methods, Files.readString() and Files.writeString(), which simplify reading and writing text files. These methods provide a more convenient way to handle file I/O operations by allowing you to read an entire file into a string or write a string directly to a file, eliminating the need for additional buffering and …

Files.readString() and Files.writeString() in Java Read More »

Java 11 New String Methods

Introduction Java 11 introduced several new methods to the String class, providing more convenience and efficiency in string manipulation. These methods simplify common string operations and enhance the overall functionality of the String class. This guide will cover the new methods added in Java 11, including isBlank(), lines(), strip(), stripLeading(), stripTrailing(), repeat(), and indent(). Key …

Java 11 New String Methods Read More »

Local-Variable Syntax for Lambda Parameters in Java

Introduction Java 11 introduced a new feature called local-variable syntax for lambda parameters. This feature allows you to use the var keyword in lambda expressions to declare the types of parameters, similar to how you can use var for local variable type inference in methods. This feature provides more flexibility in how you write lambda …

Local-Variable Syntax for Lambda Parameters in Java Read More »

Collectors.toUnmodifiableMap() in Java

Introduction Java 10 introduced the Collectors.toUnmodifiableMap() method, which is used to collect elements from a stream into an unmodifiable map. This method is part of the Java Stream API and provides a way to create read-only maps directly from streams. Once created, the resulting map cannot be modified, ensuring data integrity and immutability. Key Points: …

Collectors.toUnmodifiableMap() in Java Read More »

Collectors.toUnmodifiableSet() in Java

Introduction Java 10 introduced the Collectors.toUnmodifiableSet() method, which is used to collect elements from a stream into an unmodifiable set. This method is part of the Java Stream API and allows you to create read-only sets directly from streams, ensuring that the resulting set cannot be modified. Key Points: Immutable Set: Collectors.toUnmodifiableSet() creates a set …

Collectors.toUnmodifiableSet() in Java Read More »

Collectors.toUnmodifiableList() in Java

Introduction Java 10 introduced the Collectors.toUnmodifiableList() method as part of the Java Collections Framework. This method is used in conjunction with the Java Stream API to collect elements into an unmodifiable list. Once created, the resulting list cannot be modified, making it a convenient way to create immutable lists directly from streams. Key Points: Immutable …

Collectors.toUnmodifiableList() in Java Read More »

Java Local-Variable Type Inference (var keyword)

Introduction Java 10 introduced a new feature called local-variable type inference using the var keyword. This feature allows the Java compiler to infer the type of a local variable based on the context, eliminating the need for explicit type declarations in certain scenarios. It simplifies the code by reducing boilerplate and enhancing readability. Key Points: …

Java Local-Variable Type Inference (var keyword) Read More »

Scroll to Top