课程: Java Essential Training: Syntax and Structure
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Constructors
- [Instructor] In addition to using setter methods to assign values to fields of a class, you can also use a constructor. Constructor are used to initialize an object or set up its state in some way. All objects have a constructor. And the very first type of constructor is the default constructor. This is a default constructor. The default constructor is known as such because it does not have a parameter list. This means, if someone wanted to create a rectangle object, and they did not want to set the length or the width just yet, then they could use this constructor without passing in any values. The default constructor is typically used to assign default values to fields. In Java, a default constructor is always defined implicitly. So even if you don't declare it explicitly, as we have done here, it still exists by default under the covers. Essentially, it's a blank constructor that does nothing. Let's dissect this…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
-
-
(已锁定)
Defining classes for objects5 分钟 22 秒
-
(已锁定)
Constructors3 分钟 7 秒
-
(已锁定)
Instantiating objects4 分钟
-
(已锁定)
Objects as method parameters2 分钟 9 秒
-
(已锁定)
Objects as method return types1 分钟 55 秒
-
(已锁定)
Wrapper classes1 分钟 54 秒
-
(已锁定)
Records1 分钟 51 秒
-
(已锁定)
Code Solution: Create a car object1 分钟 12 秒
-
(已锁定)
-
-
-