In a prior video, you learn about how to use static methods that are called from a class without the class first being instantiated. But when a method needs to work with persistent data that’s stored within an object, it’s known as an instance method—that is, a method that belongs to an instance of the class.
- [Instructor] A constructor method…is a special kind of method…that's used to create an object in Java.…Whenever you instantiate a class in Java,…a constructor method is being called somewhere.…If you're using a class from an existing library,…the constructor might not always be visible to you.…For example, there are more advanced design patterns…known as factory classes and builders…that hide the use of a simple constructor,…but it's always being used at some point.…The name of a constructor method…has to match the name of the class it constructs.…
In this code, I'm using a class called MathHelper…and I instantiate it with this constructor method.…The name of the method matches the name of the class…and that's a requirement.…Now, this method isn't explicitly defined…in the MathHelper class.…And in fact from the main class,…if I hold down the Control or Command key…and then click on the method call,…I don't find the method,…instead I jump to the class.…But the method is there,…it's just not explicit.…Every class has to have a constructor of some kind.…
- Debugging Java code
- Handling exceptions
- Creating custom classes
- Working with inheritance
- Managing data collections
- Using Java packages and libraries
- Preparing a Java application for deployment
Skill Level Intermediate
1. Exception Handling and Debugging
2. Create Custom Classes
3. Work with Inheritance
4. Manage Data Collections
5. Use Java Packages and Libraries
Work with dates and times7m 12s
6. Prepare a Java Application for Deployment
Next steps1m 12s
- 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.