Compare the area of two rectangles This is my solution for a problem in my workbook. It says to create a program that accepts input from a user to compare the areas of two rectangles. Is it good or bad practice to call functions in a constructor as soon as it is initialized?

Such as this:

public Rectangle() {
System.out.println("New rectangle dimensions \n" + "---------------
---------------------------");
userInputDimensions();
calculateArea();
}


Or is it better to just call the functions from the main class and keep the constructor empty? Everything works, I'm just trying to get some general advice on how to improve this code.

Main Class

public class Main {


public static void main(String[] args) {

Rectangle rectangle1 = new Rectangle();
Rectangle rectangle2 = new Rectangle();
Rectangle.CompareAreasOfRectangles test = rectangle1.new 
CompareAreasOfRectangles(rectangle1, rectangle2);




}
}


Rectangle Class

import java.util.*;

public class Rectangle {
private double rectangleWidth;
private double rectangleLength;
private double areaOfRectangle;

public Rectangle() {
    System.out.println("New rectangle dimensions \n" + "---------------
---------------------------");
    userInputDimensions();
    calculateArea();
}

//Get Dimensions of Rectangle

private void userInputDimensions() {
    this.rectangleWidth = this.getPositiveInput("Please enter the width 
of the rectangle");
    this.rectangleLength = this.getPositiveInput("Please enter the 
length of the rectangle");
}

private double getPositiveInput(String prompt) {
    Scanner reader = new Scanner(System.in);
    double result;
    do {
        System.out.println(prompt);
        result = reader.nextDouble();
        if (result &lt;= 0) {
            System.out.println("Enter a number greater than zero.");
        }
    } while (result &lt;= 0);
    return result;
}

private void calculateArea() {
    this.areaOfRectangle = rectangleWidth * rectangleLength;
}

private double getAreaOfRectangle() {
    return areaOfRectangle;
}

// Compare areas of Rectangles

public class CompareAreasOfRectangles {
private Rectangle rectangle1;
private Rectangle rectangle2;

public CompareAreasOfRectangles(Rectangle rectangle1, Rectangle 
rectangle2) {
    this.rectangle1 = rectangle1;
    this.rectangle2 = rectangle2;

    if (rectangle1.getAreaOfRectangle() &gt; 
rectangle2.getAreaOfRectangle()) {
        System.out.println("The area of Rectangle 1 is greater than the 
area of Rectangle 2");
    } else if (rectangle1.getAreaOfRectangle() &lt; 
rectangle2.getAreaOfRectangle()) {
        System.out.println("The area of Rectangle 2 is greater than the 
area of Rectangle 1");
    } else {
        System.out.println("The areas are equal");
    }
}
}
}
It is always a best practice to use constructor only for initializing default values. Whatever logic or the function which you want to use is good to call directly from main method or separate method.