Kathryn shows you the solution to the "Create a Blueprint and an Instance" challenge. In the solution, Kathryn creates a Dog class with three properties and three methods. She also creates an instance of the Dog class in the main method of the Main class, and calls one of the Dog class’s methods.
- [Narrator] Here's a solution to the previous…create a blueprint in instance challenge.…I've chosen to represent a dog in code,…and so I've created a dog class.…Here, our dog has a name, age, a series of fetched items,…and a private fetch counter.…Here, our name is a string, our age is an int,…the series of fetched items is a string array,…and then our fetch counter is a private int.…We also have a constructor,…and this is how we're going to make dogs.…This is how dogs are created.…
Every dog that we create needs to have a name and an age,…and so basically when you create the dog,…you have to give it that as an input.…We'll see this more in the main method.…And then another method we have here is called bark.…And bark just prints out bark when you call it.…We also have get dog years, and it returns the dog years…depending on what age the dog is currently.…And our last method here is fetch,…and fetch, this is basically the dog fetching…a series of items or fetching one item…out of that series of items,…and the first thing we do in this method…
- Downloading Java 9 and choosing an IDE
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Working with inheritance and interfaces
- Learning lambda
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Control Flow
4. Beyond the 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.