Pages

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

Tuesday, February 19, 2019

Java 9 String chars() method example - Internal Implementation

Java String chars():


chars method is introduced in package java.lang.String class from Java 9 onwards. This method returns a stream of int zero-extending the char values from this sequence. Any char which maps to a surrogate code point is passed through uninterpreted. If the sequence is mutated while the stream is being read, the result is undefined.


Java String chars() method example



Syntax:

public IntStream chars​()


This method returns IntStream which holds of characters of input string and will have some light performance penalty.