Author: geonikpal

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

  • Spring Bean Annotation

    Spring Bean Annotation

    In this article, we’ll go through what Spring Bean Annotation(@Bean) is, how you can use it and when you should use it. 1. What is @Bean in Spring Spring @Bean annotation allows you to declare multiple beans in a @Configuration class, without the need to use class-level annotations such as @Component, @Service, etc. You can…

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

  • @Configuration in Spring Boot

    @Configuration in Spring Boot

    In this article, we’ll go through what @Configuration in Spring Boot is and how to use it. 1. What is @Configuration Annotation in Spring Boot We use @Configuration in Spring Boot mainly to declare new beans that will be included in the Spring Context. We can inject these beans through @Autowired Annotation wherever we need…

  • @Autowired Annotation in Spring Boot

    @Autowired Annotation in Spring Boot

    In this article, we’ll go through what @Autowired annotation does in Spring Boot and how to use it. 1. What is @Autowired in Spring @Autowired annotation allows you to inject a bean to a class (This is called Dependency Injection or DI for short). Additionally, @Autowired can be applied to each of the following: Constructor…

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

  • Spring Boot Rest Controller

    Spring Boot Rest Controller

    In this article, we’ll go through how Spring Boot Rest Controller works through detailed examples. 1. Setting up the project First of all, you need to have Java installed, if you do not you can go through these tutorials depending on the OS your machine runs: For this tutorial, we are using the IntelliJ IDEA…

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