Java In A Nutshell — Optionals & Streams API

Introduction

Optionals

Creating Optionals

ofNullable

empty

of

Methods on the Optional class

get

orElseThrow

orElse*

Optional Utility

Optionals Final

Varargs a.k.a., Spread Operator

Streams API Overview

What is the Streams API in a more technical description?

Creating a Stream

How do we use a Stream? (The juicy bit :P)

Element 1 -> Map, Map modified element 1.name -> Sits at the end of stream
Element 2 -> Map, Map modified element 2.name -> Sits at the end of stream
Stream.toArray() -> Terminates the stream
// Output:// bob0.032052957686273365 -- Our special bob printed from the stream
// bob0.5406010870099155
// bob0.47736778571943084 -- Our special bob printed from reference
Stream<SpecialBob> myStream = Stream.of(
new SpecialBob()
mySpecialBob
);
// Output:// bob0.5406010870099155
// bob0.032052957686273365 -- Our special bob printed from the stream
// bob0.47736778571943084 -- Our special bob printed from reference

Extension Methods

List<Integer>

Streams API Usage

Intermediate Operation Methods

Distinct

Sorted

Filter

DropWhile

TakeWhile

Map

FlatMap

Limit

Peek

Skip

OnClose Event

Terminal Operation Methods

Reduce

ForEach

AnyMatch

AllMatch

FindAny

FindFirst

Max/Min

Working With Primitives

Stream Concurrency — ForkJoinPool

Streams Concurrency API Usage

Streams Final

--

--

I'm just a self taught developer from England, honestly, that's it lol.

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
Alexanderkilroy

I'm just a self taught developer from England, honestly, that's it lol.