In the previous chapter it took multiple lines to construct an object and initialize it (left). With a constructor we can do it in one line (right).
Rectangle rec;
rec = new Rectangle();
rec.setWidth(11);
rec.setHeight(5);
Rectangle rec;
rec = new Rectangle(11, 5);

👉🏼 Try It

📹 Video