Learnitweb

Category: Java tutorial

  • Java isBlank() method

    1. Introduction The syntax of the isBlank() method of String class is: This method returns true if the string is empty or contains only white space codepoints, otherwise false. One important point to note here is the term white space codepoint. A character is a Java whitespace character if and only if it satisfies one…

  • String repeat method

    1. Introduction Sometimes you might need to repeat a string certain number of times. In such case, you can use String class repeat() method. The signature of repeat method is: public String repeat​(int count) – This method returns a string whose value is the concatenation of this string repeated count number of times. If this…

  • Local-Variable Syntax for Lambda Parameters

    1. Introduction Local-Variable syntax for Lambda parameters was introduced as JEP 323. This change allows var to be used when declaring the formal parameters of implicitly typed lambda expressions. The goal of this change is to align the syntax of a formal parameter declaration in an implicitly typed lambda expression with the syntax of a…

  • HttpClient in Java 11

    1. Introduction The HTTP Client was added in Java 11. This class was introduced to replace the legacy HttpUrlConnection class. Due to the issues with HttpUrlConnection, programmers used third-party libraries such as Apache HttpClient and Jetty. HttpClient is an abstract class available in java.net.http module and java.net.http package. This class represents an HTTP Client. An…

  • Concurrency vs Parallelism

    1. Introduction At first, concurrency and parallelism may seem to be the same thing but actually these are different. In Java programming, understanding the concepts of concurrency and parallelism is important for developing efficient and robust applications. Java with its libraries and features provide rich support to both concurrency and parallelism. A simple example of…

  • Improved Docker Container Integration with Java 10

    1. Introduction Java during startup normally queries the operating system to setup runtime defaults such as the number of GC threads and default memory limits. When running in a container, the operating functions used to get information provide information about the host and do not provide information about the container configuration and limits. With the…

  • Class Data sharing

    1. Introduction Class data sharing (CDS) helps reduce the startup time for Java programming language applications, particularly in smaller applications. CDS helps reducing memory footprint between multiple Java Virtual Machines (JVM). When the JRE is installed using the installer, the installer loads a set of classes from the system jar file into a private internal…

  • Optional.orElseThrow()

    1. Introduction A container object which may or may not contain a non-null value. If a value is present, isPresent() returns true. If no value is present, the object is considered empty and isPresent() returns false. Optional has a method get() which return a value if the value is present, otherwise throws NoSuchElementException. The common…

  • Java 10 Local Variable Type Inference

    1. Introduction Before discussing local variable type inference, let us review what is type inference in Java. Following is the way of declaring a list of String in Java. The compiler inferences the type of list be looking at the left hand side of the =. Let us see another example of type inference. Let…

  • Java 9 process API updates

    1. Introduction Until Java 8, Java SE provided limited support for native operative-system processes. This forced developers to resort to native code. Also, programmers have to write code based on operating system. To solve this issue, serval process API enhancements were introduced in Java 9. The java.lang.Process class is enhanced to operating specific id of…