Join David Gassner for an in-depth discussion in this video Using instance field initializers, part of Java Advanced Training.
In a previous video, I described how to use a static initializer to initialize complex…static fields in classes.…There's also syntax in Java for initializing non-static fields that might need special…handling, and I'll demonstrate this in the project instance field initializer.…This project starts out like the last one.…There is a class named OliveJar that has a static ArrayList named Olives and a static…initializer that contains code to fill in the objects within the ArrayList, then in…the Application's main method there is a reference to that static field and a loop to output…the content of each olive.…
I'll start off in the OliveJar class of this version of the project, and this time I'm…going to make the olives ArrayList non-static, I'll simply remove the static keyword and…then I'll do the same thing on the initializer, and that's what a non-static initializer looks like.…It's a block of code without any keywords before the opening brace, and this code will…be executed before any constructor methods.…
- Installing Java on Windows and Mac OS X
- Installing Eclipse
- Using new features such as simplified generics
- Working with advanced class structures (member, local inner, etc.)
- Using the Reflection API
- Navigating inheritance trees
- Managing unordered and ordered sets
- Peeking and polling with queues
- Testing and error handling
- Managing files and directories
- Working with I/O streams
- Next steps with Java
Skill Level Advanced
1. Getting Started
2. Java 7 New Features
3. Using Advanced Class Structures
4. Using the Reflection API
5. More of the Collections Framework
6. Testing and Advanced Exception Handling
Using the finally keyword5m 40s
7. Managing Files and Directories in Java 7
8. Working with I/O Streams
9. Working with Multi-threading
- 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.