Tag: core java

  • Java Lambda Expressions

    Java Lambda Expressions

    In this article, we’ll go through what Lambda Expressions are in Java and how they work. 1. What is Lambda in Java? Lambda expressions are short functions that accept zero, one, or more parameters and return a value. This value is usually an object of type Function<T, R>, Consumer<T>, Supplier<T>, etc. If we compare java…

  • 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.…

  • Collectors to Map in Java

    Collectors to Map in Java

    In this article, we’ll go through Collectors to Map method in Java, which is used to convert a stream to a map. 1. Collectors to Map overview The Collectors to Map method is used to transform a Stream of items into a Map. Note that Collectors.toMap() is a terminal operation which means you cannot perform…

  • 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…

  • Ternary Operator in Java

    Ternary Operator in Java

    In this article, we’ll go through what the Ternary Operator is in Java and how it works. 1. What is Ternary Operator in Java? The ternary operator is the ? followed by 2 : and it can be used to assign a value to a variable based on the truthiness of a condition. The syntax…

  • Java String compareTo() Method

    Java String compareTo() Method

    In this tutorial, we’ll go through compareTo() Java method of the String class. Additionally, we’ll look into compareToIgnoreCase() method and how it differs from compareTo(). 1. What is String compareTo in Java? The String compareTo() method can be used to compare two strings lexicographically based on the sum of the Unicode value of each character.…

  • String Split in Java

    String Split in Java

    In this article, we’ll go through how you can use Java string split methods of String class. 1. Java String Split Method with a Regex This method will split the string based on the regex you provided and return an array of strings with the items you want. Of course, the regex that matched will…