Tag: java

Total 182 Posts

How to Split a String in Java

Introduction

Oftentimes, we are faced with a situation where we need to split a string at some specific character or substring, to derive some useful information from it.

For example, we might want to split a phone number on the country code or data imported from a CSV file.

In

Continue Reading

Java: Convert Array to Stream

Introduction

In this tutorial, we'll be converting a Java Array into a Java Stream for primitive types, as well as objects. This can be done either via Arrays.stream(), as well as Stream.of().

Arrays.stream()

A good way to turn an array into a stream is to use the

Continue Reading

Java: Convert Stream to Array

Introduction

In this tutorial, we'll be converting a Java Stream into a Java Array for primitive types, as well as objects.

Stream.toArray()

The toArray() method is a built-in method from the Stream class which is really convenient to use when converting from a Stream to an array. It works

Continue Reading