Classes in Java: Creating & Using Anonymous Classes
Java SE 15 | Intermediate
- 7 videos | 59m 45s
- Includes Assessment
- Earns a Badge
Anonymous classes in Java allow you to define code that use-and-throw. These are classes where you define and instantiate a class simultaneously and which are anonymous, i.e., do not have a name. These are perfect in scenarios where you want a class that implements a certain interface but will not be reused beyond where it is defined and accessed. Through this course, learn to create and use anonymous classes, recognizing how they are nested, inner, and unnamed classes that either implement an interface or derive from a base class. As you advance, explore some common use cases for anonymous classes. When you're finished with this course, you'll be able to create and use anonymous classes in Java correctly, with the correct syntax, and for the proper use case.
WHAT YOU WILL LEARN
discover the key concepts covered in this coursedefine and use anonymous classesrecognize how anonymous instances are objectsillustrate the finer points of anonymous classes
implement the built-in interfaces, Comparator and Runnable, with anonymous classesperform filter operations with local and anonymous classessummarize the key concepts covered in this course
IN THIS COURSE
13m 2sIn this video, you'll learn how to implement the built-in interfaces, Comparator and Runnable, with anonymous classes. You'll discover these single method interfaces have exactly 1 method for which you need to provide an implementation. These are often implemented using anonymous classes, which will be demonstrated here. Also, observe that we've printed out the contents of the list before sorting as well as after sorting. FREE ACCESS
13m 3sIn this video, you'll learn how to make your code more compact, readable, and maintainable by using Lambda expressions. You'll begin with a simple scenario that doesn't use lambdas. Then you'll iteratively improve the solution until you get to using lambda expressions. FREE ACCESS
EARN A DIGITAL BADGE WHEN YOU COMPLETE THIS COURSE
Skillsoft is providing you the opportunity to earn a digital badge upon successful completion on some of our courses, which can be shared on any social network or business platform.Digital badges are yours to keep, forever.
YOU MIGHT ALSO LIKE
PEOPLE WHO VIEWED THIS ALSO VIEWED THESE