Pages

Showing posts with label Java 11. Show all posts
Showing posts with label Java 11. Show all posts

Friday, November 19, 2021

Java 11 String.lines() - Get Stream of Lines

1. Java 11 String Stream<String> lines() Overview


In this tutorial, We'll learn how to convert String to Stream. lines() method returns Stream of Strings. We'll go through String lines() Method Examples.

Simple words, This method break down the string into lines if input string has lime terminators.

Supported line terminators are '\n', '\r' and '\r\n'.

"\n":  a line feed character
"\r":  a carriage return character
"\r\n": a carriage return followed immediately by a line feed

Java 11 String API lines() Method Example

Java 8 Vs Java 11 - Developers Must know

1. Overview

In this tutorial, We'll learn what are the key differences between java 8 and java 11.

Java 8 is introduced on March 14th 2014 which is released with major changes after a very long time to compete with other programming languages such as scala.

Java 11 is introduced on September 25th 2018 which is after 4 years of java 8.

In the next sections, we will see the main core concepts in java 8 and java 11. And also what are the other core features added in java 9 also.
Java 8 Vs Java 11

Sunday, May 17, 2020

Java 11 Shebang example - Run As Shell Program

1. Introduction


In this tutorial, You'll be learning today how to run the java program as shell script files (shebang) from java terminal from Unix or mac os. Even you can run from docker as well. Copy the files to docker and make sure you have OpenJDK 11 installed and run with java 11 single source files command.

At the present time, You might have seen a lack of knowledge on shell programming or a bit difficult to maintain the scripts for back end jobs.

Now, Java 11 comes up with the new concept to execute the java files as shell script files like batch-job.sh file. Inside batch-job.sh file, you can write all your java code and it is completely understandable at runtime by the operating system.

Java 11 Shebang example - Run As Shell Program



Wednesday, May 29, 2019

Java 11 String API repeat​() Method Example

1. Java 11 String repeat​() Method Overview


In this tutorial, We'll learn about Java String API repeat​() Method with examples. repeat() method repeat​s the string given n number of times.

repeat() method works as it name suggests.

Java 11 String API repeat​() Method Example

1.1 Syntax

public String repeat​(int count)

This is a public method and can be accessed on string instance directly.

1.2 Parameters

count - number of times to repeat

If we pass count as 3 then string repeats 3 times.

Tuesday, May 28, 2019

Java 11 String API isBlank() Method Example

1. isBlank Method Overview

In this tutorial, We'll learn about new java 11 string isBlank() method and explanation with examples. And also how to check the string is blank or not using isBlank() method.

This method is introduced in Java 11.
Read complete article on What is new in Java 11 String API.

Java 11 String API isBlank() Method Example

Wednesday, May 8, 2019

Java 11 String API New Methods

1. Java 11 String API New Methods Overview:

Java 11 is a new updated version with lots of changes similar to java 8. Java is free to use in production environments till java 10. But, java 11 onwards we should get license to use production environments.

String is a collection of characters including alphabets, numeric, special characters and as well supports 256 bit character set (any character).
Java 11 String API

Java strings are constants that means once created, values of string can not be changed. This is called as Immutable. Immutable is to get the advantage sharing the objects in multi-threading.

Following are the new methods added in Java 11 java.lang.String class.

Java 11 - String API New Methods

1.1 Java 11 String API Additions:

1) isBlank()
2) lines()
3) repeat​(int count)
4) strip()
5) stripLeading()
6) stripTrailing()