This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Jerry Kilpatrick: ... I am not familiar with this syntax. What does it do? What is it's name? ...
I'm guessing that the syntax you're referring to is the anonymous class definition.
Basically, an anonymous class looks like a constructor call, but before the closing semicolon, a class definition is slipped in with braces. The result is a class that implicitly extends the class (or implements the interface) identified after the keyword "new."
Furthermore, the instance of this anonymous class is automatically upcast to the type it extends (or implements).
In this particular case, we have an anonymous class that extends JLabel, and the new instance is upcast to type JLabel. [ November 30, 2005: Message edited by: marc weber ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org