Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static inner class

 
Ed Zeval
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a couple of inner classes in my code. Someone told me that I should make them static. Why would I want to do that?

Thanks!
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do your inner classes do? and what does your outer most class do?

Justin Fox
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know what the difference is, technically?
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the inner class references some instance fields or methods of the outer class you will probably not even be able to make it static.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
provide some sample code if you want specific assistance
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic