Join Peggy Fisher for an in-depth discussion in this video Instantiating classes, part of Java Essential Training for Students.
- Okay, now comes the fun part.…Let's return to our Payroll application.…We have created the employee and the address classes…so let's take a look at the main class,…which I have open here, payroll.java.…You'll notice line 10 has "public static void main".…In this class, we're going to be able to create…objects for the address and the employee.…We're then going to print the values back out again.…We're going to try and change some of the values,…as well as use our "compareTo" methods.…
When we create a new object from a class definition,…it is actually called an "instance" of the class…and that's why we say we've instantiated a new object.…It is important to note that you must…instantiate an object by using a keyword "new".…We can create any number of employees…using this process.…For our example, I'm going to create two…employee objects but before I can create the employee,…I need to instantiate an address object.…
On line 11, I declare address "a1".…"a1" is my variable name.…I say "equals new", there's that key word…
- Getting started with parsing
- Reviewing data types
- Using decisions
- Creating user-defined methods
- Command-line debugging
- Exploring the Java API
- Creating and instantiating classes
- Working with interfaces
- Storing items with arrays
Skill Level Intermediate
Q: How can I make my debugger function like the author’s?
1. Command Level Programming
2. Basics Review
4. Java API
5. Simulations and Algorithm Analysis
6. Classes and Objects
7. More on Classes
8. Data Structures
- 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.