Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn Java anonymous classes in 5 minutes! 🕵️‍♂️
Play lesson

Java tutorial for beginners ☕ - Learn Java anonymous classes in 5 minutes! 🕵️‍♂️

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse public class Main { public static void main(String[] args) { // Anonymous class = A class that doesn't have a name. Cannot be reused. // Add custom behavior without having to create a new class. // Often used for one time uses (TimerTask, Runnable, callbacks) Dog dog1 = new Dog(); Dog dog2 = new Dog(){ @Override void speak(){ System.out.println("Scooby Doo says *Ruh Roh*"); } }; dog1.speak(); dog2.speak(); } } public class Dog { void speak(){ System.out.println("The dog goes *woof*"); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere