Introduction to Java Streams

What are Java Streams? A Java stream is a sequence of elements of a specific type that are consumed from a source like Collections, arrays, or I/O resources. Streams are similar to collections in that they can both be used to process and aggregate data. However, there are some big differences. Although the idea of

read more

What is the Java Supplier Interface?

The Java Supplier interface of the java.util.function package is a functional interface that is often used as an assignment target for lambda expressions. The get() method is the class’s only abstract method, which takes no input and returns an output. For more information on functional interfaces in Java click here: What is a Java Functional

read more

What is the Java Function Interface?

The Java Function interface of the java.util.function package is a functional interface that is often used as an assignment target for lambda expressions. The apply(T t) method is the class’s only abstract method, leaving it as the only one without a default implementation. Here is an overview of the various methods in the Function interface:

read more

What is the Java Predicate Interface?

The Java Predicate interface of the java.util.function package is a functional interface that is often used as an assignment target for lambda expressions.  The test(T t) method is the class’s only abstract method, leaving it as the only one without a default implementation.  Here is an overview of the various methods in the Predicate interface:

read more

What is the Java Consumer Interface?

The Java Consumer interface of the java.util.function package is a functional interface that is often used as an assignment target for lambda expressions. accept(T t) is the interface’s single abstract method which takes an object as input and returns nothing. The andThen(Consumer<? super T> after) method provides a simple way to string multiple Consumer objects

read more

What is a Java Functional Interface?

Simply put, a Java functional interface is an interface with a single abstract method. Functional interfaces were released with Java 8 and provide target types for lambda expressions. The java.util.function package contains various general purpose functional interfaces such as Predicate, Consumer, Function, and Supplier. For an an intro to Java lambda expressions click here: What

read more

What are Lambdas in Java?

In general a lambda expression is an anonymous function, which means for some combination of inputs, there is a specific output. In the context of Java, a lambda expression is a kind of anonymous method with a more compact constructor syntax. Lambdas in Java are first class citizens, and can be passed as method parameters

read more

How to Decode URLs in Hive

Decoding URLs and strings can be a common task, especially when working with web data. This is easy to do in a language like Java or Python, but what about in Hive? Luckily, this is fairly easy as well. Decoding URLs in Hive with Reflection The first and easiest approach is to use the reflect()

read more

How to Generate a UUID in Java

UUID stands for Universally Unique Identifier. UUIDs are used as IDs (to identify) unique objects or records. An easy way to generate UUIDs in Java is to use the java.util.UUID class. Different variants and variant-versions exist for UUID objects. The methods of this class generally manipulate the Leach-Salz variant, although the constructors allow the creation

read more

How to Create a Max Heap using an Array in Java

A Heap/Binary Heap is a data structure that takes the form of Binary Tree. Heaps are commonly used to implement priority queues (check out the PriorityQueue class in Java). Priority queues are great ways to identify the highest (or lowest) priority items in a collection. A Max Heap is a binary tree data structure in

read more