课程: Java Object-Oriented Programming
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Understanding the difference between class and instance members - Java教程
课程: Java Object-Oriented Programming
Understanding the difference between class and instance members
- [Instructor] So far, we've created a class blueprint and built instances using a constructor. We can continue to organize our code by using static and non-static members. In fact, we've already been writing code that's non-static. Non-static members are parts of a class that are accessible via an instance and belong to that instance. This means you'll need to create an instance in order to access a non-static member. In our Tree example, the height, trunk and treeType are all examples of non-static members. Or specifically, non-static attributes. You'll have to create a tree in order to access the values of these attributes. The announceTallTree behavior is also a non-static member. It's a non-static method that uses an instance's height and treeType in order to announce whether the tree is tall. We could also refer to these non-static members as instance members because you have to create an instance in order to use it or access it. So what about a static member? A static member is…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
(已锁定)
Using classes as blueprints4 分钟
-
(已锁定)
Building objects with a constructor2 分钟 48 秒
-
(已锁定)
Using concrete instances for application logic4 分钟 32 秒
-
(已锁定)
Understanding the difference between class and instance members4 分钟 54 秒
-
(已锁定)
Exploring a built-in Java class4 分钟 5 秒
-
(已锁定)
Challenge: Build an employee class1 分钟 8 秒
-
(已锁定)
Solution: Build an employee class3 分钟 11 秒
-
(已锁定)
-
-
-
-
-