This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes I want to create a class but the class no longer useful in other place Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I want to create a class but the class no longer useful in other place" Watch "I want to create a class but the class no longer useful in other place" New topic
Author

I want to create a class but the class no longer useful in other place

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 580
I want to create a class but the class no longer useful in other place,

how I create class,please suggest

Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3995
    
  18

What do you mean, the class is no longer useful in other places?

Please give more details about what you're trying to do.


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 580


here the class b is used only inside of class A, no where else it is used.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63225
    
  69

Perhaps you could define it as an inner class?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 580
please suggest what type of inner class best suited for this and using an inner class is a best practice?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 63225
    
  69

I use inner classes only when the class only makes sense within the context of the parent class. I think it is something that is overused in general and your caution is warranted.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: I want to create a class but the class no longer useful in other place
 
It's not a secret anymore!