From the course: Oracle Java Foundations
Unlock this course with a free trial
Join today to access over 24,000 courses taught by industry experts.
Constructor: Demo - Java Tutorial
From the course: Oracle Java Foundations
Constructor: Demo
(upbeat music) (logo whooshing) - [Instructor] Exercise 6-2, add a clothing constructor. We'll add a constructor to a Clothing class to initialize the description and price fields. Then we'll add an extra parameter to the Clothing class constructor to accept a value for the size field and initialize this field. And then we'll modify the initialization of all Clothing objects in the main method to use a newly added constructor. So, we need to add a constructor to Clothing class to initialize description and price, so we go back to NetBeans, and we go to Clothing. Remembering what we did, come down a little bit from our variable declaration, right-click, and select Insert Code, select Constructor, select description and price. Here we go. Click Generate, and there's our constructor. Great. Add an extra parameter to the Clothing class to accept a value for the size field, and initialize this field. All right. So, we're going to add an extra parameter to take the size. And we don't have a…