Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Anonymous Inner Class Definition (OCP7 Study Guide by Mala Gupta)

 
Ranch Hand
Posts: 59
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

On p158 it says:

"An instance of anonymous inner class can be assigned to any type of variable (static variable, instance variable, or local variable), method parameter, or returned from a method."



But anonymous classes can't be static, right, so the statement might be wrong? Am I missing something?

Thanks!
 
Enthuware Software Support
Posts: 4467
42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Yin Stadfield wrote:Hi guys,

On p158 it says:

"An instance of anonymous inner class can be assigned to any type of variable (static variable, instance variable, or local variable), method parameter, or returned from a method."



But anonymous classes can't be static, right, so the statement might be wrong? Am I missing something?

Thanks!


Anonymous class isn't static but you can certainly assign an instance of this class to a static variable. It is the variable that is static, not the class.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic