Pages

Showing posts with label java.lang. Show all posts
Showing posts with label java.lang. 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

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

Java String intern() Method Example

1. Overview

In this post, We'll learn String intern() method in java with examples and This is part of java.lang package. Intern method is invoked automatically on every string literal creation.

String is immutable that means a new String object will be created for every operation or invoking any method on string object. In another words, Original String content will not be modified.


Java String intern() Method Example



Thursday, March 14, 2019

Java String copyValueOf​ method example - Internal Implementation

Java String copyValueOf​ method:

copyValueOf​ method is present in the String class which is in package java.lang.String. copyValueOf​ is used to convert character array into String that means it creates a new String with contents of array elements. In this tutorial, We will learn String copyValueOf​ method syntax, String copyValueOf​ method example and String copyValueOf​ method internal implementation.

String has overloaded copyValueOf​ methods and both are static methods which can be accessed by class name instead of creating object for String class.



copyValueOf​ Syntax 1: 

public static String copyValueOf​(char[] data);


Returns the string representation of the char array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the returned string.


String copyValueOf​ method


Parameters:

data - the character array.

Returns:

A String that contains the characters of the character array.