Join Peggy Fisher for an in-depth discussion in this video Instantiating classes, part of Up and Running with Java.
- Now that we've created the property class,…let's switch to our main class…so we can create a list of properties…for our real estate business.…When we create a new object from a class definition,…it is called an "instance" of that class.…It's very important to note that you must instantiate…an object by using the keyword "new."…For our example, I'm gonna create two property objects,…one for land and one for an estate.…I start by using the class name, Property.…Now, I need to give this a variable name,…we'll call it land, = new Property…This is how we instantiate a new object.…
Because land does not have beds and baths,…I'm gonna use the first constructor,…which only requires the asking price.…So let's say the land is worth $10,000.…The next field represents the type of property.…in our case, it's land.…And then the last part I need here is the acreage,…the size of the lot.…So I'll go ahead and say 2.1 acres…and now, right below that,…let's declare a second object.…This one we'll call, "estate."…Property estate = new Property…
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.