Learn to inspect fields with Java reflection.
- [Instructor] Let's begin our study of reflection…by learning how to introspect fields.…Here's the class, student,…and it has one field, gpa.…Notice that it's extends person,…and person has fields familyName and firstName.…Let's look at a test.…The first thing that we do…when we use introspection or reflection,…is we obtain a class object.…We can obtain a class object…either from a class or from an object.…
Now we have a slight problem…in that the lower case C-L-A-S-S…is a reserved word in java.…By convention, instead of using lower case C-L-A-S-S,…we use lower case C-L-A-Z-Z.…After we obtain this class object,…we assert that it's not null.…Now that we know we have a good class object,…we'll use its method, getDeclaredFields…to initialize array that we'll call fieldsArray.…
In particular, the type for each element…in this array is the type, field.…If we look at our import statements,…we'll see that field is a member of java.lang.reflect.…Let's run this test.…We see that introspection found one field.…In other words, it found the field associated with student,…
- The IMQAV model
- Downloading software
- Installing and setting up a Java coding environment
- Mock tests
- Code coverage
- Using windows, views, and modes in IntelliJ IDEA
- Creating classes and attributes
- Creating constructors
- Casting variables
- Matching literals with regular expressions
- Regular expressions
- Design patterns
Skill Level Intermediate
Java: Database Integration with JDBCwith David Gassner2h 51m Intermediate
NumPy Data Science Essential Trainingwith Charles Kelly3h 54m Intermediate
1. Getting Started with Java
2. Test-Driven Development
3. IntelliJ IDEA
4. Object-Oriented Java
6. Regular Expressions (Regex)
8. Design Patterns
9. Applying Data Science
- 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.