Introduced in Java 8, streams are a powerful tool to process collections of objects. Streams are simply wrappers around data which means they do not store data nor do they modify the underlying data source. Streams support many convenient and high-performance operations expressed succinctly with lambdas that can executed sequentially or in parallel.

In this article I will first explain the basics of streams, then I will go through some more advanced topics such as stream specializations, parallel streams and infinite streams before finally ending with when and why we should use streams instead of traditional for loops.


“Clean code should read like well-written prose” — Robert C. Martin

Stop writing code comments.

There is usually a high correlation between bad code and code with a lot of comments. This is the most obvious sign of messy source code.

The goal of every programmer should be to write code so clean and expressive that code comments are unnecessary. The purpose of every variable, function and class should be implicit in its name and structure. When you need to write a comment, it usually means that you have failed to write code that was expressive enough. …

What is a primitive type and a wrapper object in Java? How does the compiler handle conversion between the two? When should you use a primitive type or a wrapper object?

Image by NegativeSpace by Food

Primitive Types

Java defines eight primitive data types: byte, short, int, long, float, double, boolean and char. All other variables in java are object reference types.

Primitive types in Java are called literals. A literal is the source code representation of a fixed value in memory. Each primitive type varies in its size and the way in which it is stored.

Primitive Data Type Sizes

+-----------+---------+-------------------------+ | Data Type | Size | Range | +-----------+---------+-------------------------+ | byte | 1 byte | -128 to 127 | | short | 2 bytes | -32,768 to 32,767 | | int | 4 bytes | -2^31 to 2^31-1 | |…

Brian Norlander

Software developer currently living and working in Japan.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store