Tag: java

  • Multithreading in Java

    Multithreading in Java

    In this article, we will learn what multithreading is and how to multithread in Java. 1. Multithreading in Java Overview Java Multithreading allows us to execute multiple tasks at the same time preventing our application from hanging for a long time giving the impression it has frozen or crashed. 1.1 What’s a Thread? To understand…

  • How to Initialize an Array in Java

    How to Initialize an Array in Java

    In this article, we’ll go through how you can initialize an array in java, through detailed examples. 1. How to Initialize a 1D Array To create a one-dimension array in Java, the formula is the following: For example, we could initialize an array of type Person and length 3, with the following command: In addition,…

  • Math.pow in Java

    Math.pow in Java

    In this article, we’ll go through Math.pow() method in Java and how it works. 1. What is Math.pow in Java Math.pow method of java.lang package is used to calculate the ax provided you pass a base(a) and an exponent(x) as parameters. The signature of Math.pow is the following: Math.pow always returns a double. Additionally, double…

  • For Each Loop in Java

    For Each Loop in Java

    In this article, we’ll go through what for each loop in Java is, and how you can use it. 1. What is a For Each Loop For Each Loop is like the classic for loop, but with a much simpler syntax than the classic for a loop as you only need to know the name…

  • Java Static Keyword

    Java Static Keyword

    1. What does static mean in java? In this tutorial, we will learn everything about the static keyword and its usage in the Java language. The modifier static keyword is often used to make variables and methods static, which means they are not instance members, they are class members instead. In other words, they are…

  • Java Functional Interface

    Java Functional Interface

    In this article, we’ll go through what Functional Interface is in Java and how you can use them. 1. What is a Functional Interface in Java? Functional Interfaces were introduced in Java 8 and these Interfaces are annotated with @FunctionalInterface annotation. By definition, a Functional Interface is an Interface that has exactly one abstract method.…

  • Java 8 Optional

    Java 8 Optional

    In this article, we’ll talk about Java 8 Optional class and how you can take full advantage, through detailed examples. 1. What is Optional in Java? Optional is a wrapper class that was introduced in Java 8, in order to have a more elegant way to handle null values. Also Optional works in conjunction with…

  • Java Stream Reduce

    Java Stream Reduce

    In this article, we’ll go through how you can use the Java Stream Reduce method of Stream API. 1. Java Stream Reduce Overview In general, reduce methods are used to combine multiple values into one result; Java stream.reduce() does the same. Also, note that unlike map() and filter(), reduce() is a terminal operation so you…

  • Java Stream Map

    Java Stream Map

    In this article, we’ll go through the Java Stream map() method through detailed examples. 1. Java Stream Map Method Overview The stream.map() method is used to transform an object or primitive into something else. The syntax of this method is the following: The function could have one of the following syntaxes: 1.1 One-Line Lambda The…

  • Java Stream Filter

    Java Stream Filter

    In this article, we’ll go through the Java Stream filter() method through detailed examples. 1. Java Stream Filter Method Overview The stream.filter() method is used to filter an object or a primitive based on the truthness of a boolean. The syntax of this method is the following: The predicate could have one of the following…