Super() function with no parameters

When I look for Lambda expressions, I come across this code using super() keywords. And I just know that the super keyword in Java is a reference variable that is used to refer to an object’s immediate parent class. However, the keyword super() with no argument and no parents class is used in this code. So that’s why we have super().

package com.gpcoder.lambda;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

class Product {
 int id;
 String name;
 float price;

    public Product(int id, String name, float price) {
        super();
        this.id = id;
        this.name = name;
        this.price = price;
    }
}

public class LambdaExpression6 {

    public static void main(String[] args) {

        List<Product> list = new ArrayList<>();
        list.add(new Product(1, "Samsung A5", 17000f));
        list.add(new Product(3, "Iphone 6S", 65000f));
        list.add(new Product(2, "Sony Xperia", 25000f));
        list.add(new Product(4, "Nokia Lumia", 15000f));
        list.add(new Product(5, "Redmi4 ", 26000f));
        list.add(new Product(6, "Lenevo Vibe", 19000f));

        // using lambda to filter data
        Stream<Product> filtered_data = list.stream().filter(p -> p.price > 20000);

        // using lambda to iterate through collection
        filtered_data.forEach(product -> System.out.println(product.name + ": " + product.price));
    }
}

I read an article that claims it has additional use, such as providing the syntax for invoking the base class constructor with no parameters. Except for java.lang.Object, all classes have a base class. Is that right? Can someone explain me?

I read an article that claims it has additional use, such as providing the syntax for invoking the base class constructor with no parameters. Except for java.lang.Object, all classes have a base class. Is that right? Can someone explain me?

yes, absolutely true, but I think you are confusing something. super() accesses the “superclass”, also called “base class” or “parent class” sometimes. These 3 are the same, just different names. Superclass, as far as I know, is the proper term though.

An additional note: The super()-call in your Product-class is unnecessary. You only need it to access a superclass, that is not Object. The Product-constructor will behave exactly the same with or without that super() call.

A tip: maybe try to read about these topics on stack overflow. The article you linked is correct, I found no error. But the wording was very confusing to me.