File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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: 576
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: 3647
    
  17

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

Please give more details about what you're trying to do.
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576


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: 61457
    
  67

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: 576
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: 61457
    
  67

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I want to create a class but the class no longer useful in other place