Use of innerclasses

pls let me know, exactly what is the use of inner classes. In which scenarios we need to implement innerclass.

http://onesearch.sun.com/search/onesearch/index.jsp?qt=why+inner+class&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums

Similar Messages

  • Please give me the information when to use inner classes in applications

    HI,
    please give me when to use the innerclasses

    > HI,
    please give me when to use the innerclasses
    Use them when you want to create a class within another class.
    Now gimme all 'er Dukes!!!

  • Using libraries in NetBeans 6.1

    Suppose you have two classes that are in separate files but the same package. In order for one class to access the other that it references that is in the same package, what do you need to do? What I did was add the project that contains the referenced class to the Libraries folder (listed under the Projects tab) that's inside the file in which its referenced. I don't understand why I needed to do this since both classes are in the same package (and in the same directory). I believe I created the project files correctly because for each file I selected New Project, then Class Library, and I clicked on the Source Packages tab under the Projects tab and added a new Java package...The code for the two classes are listed below (Note, I don't know if this would make a difference, but the IDE I used is NetBeans 6.1):
    //: innerclasses/controller/Event.java
    // The common methods for any control event.
    package innerclasses.controller;
    public abstract class Event {
      private long eventTime;
      protected final long delayTime;
      public Event(long delayTime) {
        this.delayTime = delayTime;
        start();
      public void start() { // Allows restarting
        eventTime = System.nanoTime() + delayTime;
      public boolean ready() {
        return System.nanoTime() >= eventTime;
      public abstract void action();
    } ///:~
    //: innerclasses/controller/Controller.java
    // The reusable framework for control systems.
    package innerclasses.controller;
    import java.util.*;
    public class Controller {
      // A class from java.util to hold Event objects:
      private List<Event> eventList = new ArrayList<Event>();
      public void addEvent(Event c) { eventList.add(c); }
      public void run() {
        while(eventList.size() > 0)
          // Make a copy so you're not modifying the list
          // while you're selecting the elements in it:
          for(Event e : new ArrayList<Event>(eventList))
            if(e.ready()) {
              System.out.println(e);
              e.action();
              eventList.remove(e);
    } ///:~Similarly, how do you import the library innerclasses.controller other than writing "import innerclasses.controller;?" I did the same as listed above (adding the two project files above that are from the same package to the Libraries folder that's inside the file).
    Thanks in advance!

    hi it is unlikely people will answer you here because it is about netbeans. this is a java site so they will probably tell you to go to a netbeans site. the one i use is nabbles netbeans just do a search on google to find it.
    you might get lucky here but i doubt it because most people here use notepad and run programs from command prompt. so they might not even know anyway. also i think there is a tutorial at the netbeans sites about transfering libraries they tell you how in some of the introductory tutorials. i think one of the tutorials in relation to setting up a database using derby shows you how to do it but i can't remember.
    your best bet is nabble good luck.

  • Help,about why we use inner class?

    Hi,
    when i read "java Tutorial"
    i found there is one chapter about inner class .
    i copy it down as follow.
    the context is about there is a class Stack, and this class want to implement some function of interface Iterator,but as the book said
    we should not let class Stack implement the Iterator directly, we should add a inner class inside the Stack .
    i know it's very import ,but i still can not understand the reason why add a inner class here.
    hope somebody can explain it a little more for me or give an example.
    thank in advance!
    Iterator defines the interface for stepping once through the elements within an ordered set in order. You use it like this:
    while (hasNext()) {
    next();
    The Stack class itself should not implement the Iterator interface, because of certain limitations imposed by the API of the Iterator interface: two separate objects could not enumerate the items in the Stack concurrently, because there's no way of knowing who's calling the next method; the enumeration could not be restarted, because the Iterator interface doesn't have methods to support that; and the enumeration could be invoked only once, because the Iterator interface doesn't have methods for going back to the beginning. Instead, a helper class should do the work for Stack.
    The helper class must have access to the Stack's elements and also must be able to access them directly because the Stack's public interface supports only LIFO access. This is where inner classes come in.
    Here's a Stack implementation that defines a helper class, called StackIterator, for enumerating the stack's elements:
    public class Stack {
    private Object[] items;
    //code for Stack's methods and constructors
    not shown
    public Iterator iterator() {
    return new StackIterator();
    class StackIterator implements Iterator {
    int currentItem = items.size() - 1;
    public boolean hasNext() {
    public Object next() {
    public void remove() {
    or you can visit here
    http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html

    the context is about there is a class Stack, and this
    class want to implement some function of interface
    Iterator,but as the book said
    we should not let class Stack implement the Iterator
    directly, we should add a inner class inside the
    Stack .Simply because the implementation of the Iterator is nobody's business. By declaring it to be a private inner clss, nobody will ever know about it and only see the Iterator interface.

  • USE OF INNER CLASS

    Dear All
    PLease Expalin Why do we USE INNER CLASS What are the benefits of it.
    Help is Greatly Appreciated.

    Check out http://java.sun.com/docs/books/tutorial/java/javaOO/innerclasses.html

  • When Should I use the Inner Classes ?

    When Should I use the Inner Classes ?
    What is the advantage(s) and the disadvantage(s) ?

    When I use innerclasses?
    1) Allmost allways when I need simple owner child behavior.
    2) When I need a behaviour, that is quite small, and used only once, I make it anonymous inner class. For example specialised streams and threads.
    3) Enumerations

  • Obtaining list of classes used in an application

    I want to be able to obtain a list of all the classes and interfaces that an application uses
    I have been looking at the Class Object but with limited success
    I can get only limited things from the class
    eg the superclasses, interfaces, innerclasses, and public variables
    but I want to be able to get which private classes are used also
    the code below shows my test code to get info about a class
    Class testClass = (new java.awt.Panel()).getClass();
    Class classList[] = testClass.getClasses();
    for(int i = 0; i < classList.length; i++)
         System.out.println("class "+i+" = "+classList);
    Class innerClassList[] = testClass.getDeclaredClasses();
    for(int i = 0; i < innerClassList.length; i++)
         System.out.println("innerClass "+i+" = "+innerClassList[i]);
    java.lang.reflect.Field fieldList[] = testClass.getFields();
    for(int i = 0; i < fieldList.length; i++)
         System.out.println("field "+i+" = "+fieldList[i]);
    java.lang.reflect.Field innerFieldList[] = testClass.getDeclaredFields();
    for(int i = 0; i < innerFieldList.length; i++)
         System.out.println("innerField "+i+" = "+innerFieldList[i]);
    Object interfaceList[] = testClass.getInterfaces();
    for(int i = 0; i < interfaceList.length; i++)
         System.out.println("interface "+i+" = "+interfaceList[i]);
    Class nextSuper = testClass;
    while(nextSuper != null){
         System.out.println("Class "+nextSuper);
         nextSuper = nextSuper.getSuperclass();
    The reason that I want to do this is:
    When I use an application I want to be able to get the version of each of the classes I use.
    Ideally I would build up a set of classes used in the application (and the classes that those classes use, etc, etc)
    as I did this I would filter for things that start with my class hierarchy.
    and I would save the public String of each class that stores the version.
    Then heypresto I would have a list of all the classes of mine that are used and their version numbers.

    The idea is to write your own class which extends classloader, then use an instance of that to load the program you're trying to examine. When java wants to use a class it calls a classloader giving it the class name and package e.g. "java.lang.String". The classloader then checks to see if the class is already there, and if not attempts to load it, usually from a .class or .jar file.
    When classes loaded with a particular class loader go looking for other classes they call the classloader than loaded them.
    So if you load your main program class through your own classloader then any classes it demands (and those they demand), will also be looked for through your classloader. Since class loading is a dynamic process you actually need to run the application (having loaded your main class use getMethod to get the main method then Method.invoke(..).
    Mind you if java -verbose:class does the job (and it looks to me like it does) that's a lot simpler.
    Just run your program with that and analyse the resulting list of load events.

  • How do I use Edge Web Fonts with Muse?

    How do I use Edge Web Fonts with Muse - is it an update to load, a stand alone, how does it interface with Muse? I've updated to CC but have no info on this.

    Hello,
    Is there a reason why you want to use Edge Web Fonts with Adobe Muse?
    Assuming you wish to improve typography of your web pages, you should know that Muse is fully integrated with Typekit. This allows you to access and apply over 500 web fonts from within Muse. Here's how you do it:
    Select a text component within Muse, and click the Text drop-down.
    Select Add Web Fonts option, to pop-open the Add Web Fonts dialog.
    Browse and apply fonts per your design needs.
    Muse also allows you to create paragraph styles that you can save and apply to chunks of text, a la InDesign. Watch this video for more information: http://tv.adobe.com/watch/muse-feature-tour/using-typekit-with-adobe-muse/
    Also take a look at these help files to see if they help you:
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-1.html
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-2.html
    http://helpx.adobe.com/muse/tutorials/typography-muse-part-3.html
    Hope this helps!
    Regards,
    Suhas Yogin

  • How can multiple family members use one account?

    My children have iphones, ipads, ipods and mac books, my problem is how do you use home sharing with the devices and not get each others data.  My Husband just added his iphone to the account and got all of my daughters contacts.  I understand they could have there own accounts but if i buy music on itunes and both children want the same song, I don't feel i should have to pay for it twice.  Is there away we can have home sharing on the devices and they can pick and choose what they want? and is this icloud going to make it harder to keep their devices seperate?

    My children have iphones, ipads, ipods and mac books, my problem is how do you use home sharing with the devices and not get each others data.  My Husband just added his iphone to the account and got all of my daughters contacts.  I understand they could have there own accounts but if i buy music on itunes and both children want the same song, I don't feel i should have to pay for it twice.  Is there away we can have home sharing on the devices and they can pick and choose what they want? and is this icloud going to make it harder to keep their devices seperate?

  • Iphoto crashing after using mini-dvi to video adapter

    Hi, IPhoto on my Macbook is crashing. I can open it, then as soon as I scroll down it locks up and I have to force quit.
    This started happening right after I used a Mini-DVI to Video Adapter cable to hook my macbook up to my TV. The adapter/s-video connection worked and I was able to see the video on the tv. But iphoto immediately locked up the computer when I went to slide show and now it locks every time I open it.
    Any ideas?
    Thank you:)
    Dorothy

    It means that the issue resides in your existing Library.
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    Regards
    TD

  • How do multiple family members use iTunes.? One account or multiple?

    How do multiple family members use iTunes. One account right now but apps gets added to all devices and iTunes messages go to all devices.  Can multiple accounts be setup and still have ability to share purchased items?

    Hey Ajtt!
    I have an article for you that can help inform you about using Apple IDs in a variety of ways:
    Using your Apple ID for Apple services
    http://support.apple.com/kb/ht4895
    Using one Apple ID for iCloud and a different Apple ID for Store Purchases
    You can use different Apple IDs for iCloud and Store purchases and still get all of the benefits of iCloud. Just follow these steps:
    iPhone, iPad, or iPod touch:
    When you first set up your device with iOS 5 or later, enter the Apple ID you want to use with iCloud. If you skipped the setup assistant, sign in to Settings > iCloud and enter the Apple ID you’d like to use with iCloud.
    In Settings > iTunes and App Stores, sign in with the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match). You may need to sign out first to change the Apple ID.
    Mac:
    Enter the Apple ID you want to use for iCloud in Apple () menu > System Preferences > iCloud.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in Store > Sign In. In iTunes 11, you can also click iTunes Store > Quick Links: Account.
    PC (Windows 8):
    Enter the Apple ID you want to use for iCloud in the Control Panel. To access the iCloud Control Panel, move the pointer to the upper-right corner of the screen to show the Charms bar, click the Search charm, and then click the iCloud Control Panel on the left.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in iTunes. In iTunes 10, select Store > Sign In. In iTunes 11, click iTunes Store > Quick Links: Account.
    PC (Windows 7 and Vista):
    Enter the Apple ID you want to use for iCloud in Control Panel > Network and Internet > iCloud.
    Enter the Apple ID you want to use for Store purchases (including iTunes in the Cloud and iTunes Match) in iTunes 10 in Store > Sign In. In iTunes 11, click iTunes Store > Quick Links: Account.
    Note: Once a device or computer is associated with your Apple ID for your iTunes Store account, you cannot associate that device or computer with another Apple ID for 90 days. Learn more about associating a device or computer to your Apple ID.
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Using SQVI to generate report of open and released delivery schedule lines

    All,
    I'm using SQVI  to generate an excel spreadsheet for some buyers to show open released schedule lines because they are a 1 line item per scheduling agreement company.
    I used the logical database MEPOLDB instead of a table joint and pulled fields from EKKO(vendor, SA #,&purchasing group), EKPO(Material Number), EKEH(schedule line type), and EKET(delivery date, scheduled qty,previous qty).
    Does this sound like I'll get the results I want on paper as long as I use the right selection criteria, because the report I'm getting isn't quite what I expect? I am unable to identify which lines are authorized to ship vs. trade-off zone, planning, etc. in the report thus far.

    Hi Mark,
                 I have faced same requirement. I am not sure about transporting to TST and PROD. I done by this way.
    After generating SQVI program in DEV , I assigned that program  to a transaction and tested in DEV. Later i have regenarated SQVI in Production. then I assigned the generated Program to same transaction in DEV. And transported the Tcode assignment of program to Production..
    About authorization , if its not sensitive report, BASIS can restrict at transaction level.
    Regards,
    Ravi.

  • Using Mini DVI to VGA adapter on MacBook

    I bought the adapter from Apple & hooked up my LCD monitor to the MacBook, but the video I get on the monitor is different that on my laptop. It has an old screen background & the dock but nothing on my desktop shows up. Also, when I'm plugged to the monitor, my dock disappears on the laptop screen. Is there some setting I need to change? It worked fine with my G4 PowerBook.
    Thanks for any help....
    MacBook   Mac OS X (10.4.6)  

    i use the mini dvi-vga adapter in my classroom almost everyday. It sounds like your new monitor is running as a side by side monitor to your display instead of a "replacement" display.
    To get your projector/monitor to basically show whatever is on your macbook screen once you've hooked up press F7....this should make your projector/monitory become your display with your dock & all of your desktop stuff. Your new monitor will completely mirror your display.
    THis should do what you're looking for.

  • Using mini-DVI to VGA adapter to Samsung display

    I have 2009 late model of mac mini, The text on display looks washed out, not clear or sharp at all from day one, I thought it was the old model of monitor, tried the same cable to another monitor on another computer, SAME. so I thought the problem could be the cable or adapter.
    It's hard for me to believe is the signal from computer. I'm using VGA adapter made by Dynex bought from Best Buy.
    Anybody has suggestions?? Thanks

    Yeah, My old Samsung is lcd synmaster 17", bought many years ago at around $1000. Crazy, crazy price looked back. It's fine when I used it on the retired old Dell. It must be the adapter, trying not to buy another VGA adapter, could not image my next lcd will use one, anyway.
    This cable has only 14 pins vs 15 pins on the other cable, not sure if it matters?? Or if Safari has anything to do with it??
    Thank for you reply...

  • Using S-Video w/ the Mini DVI to Video Adapter

    I just purchased a MacBook last week and I also purchased a Mini DVI to Video adapter for it so I can use the built-in DVD player to watch movies on my TV. I have a composite to composite cable and that worked fine when I connected the cable between the Mini DVI to Video Adapter and my TV. However, when I tried to use a S-Video cable and connected that between the Mini DVI to Video Adapter and my TV; then I got no picture at all. All I saw on the TV was a picture of the MAC desktop w/o the dock and the movie or nothing else played at all.
    Is the composite connection a better connection for the MAC, or, are there some settings I need to work with on the MAC to get the S-Video connection to work?

    I managed to figure this one out, by fluke. The MacBook has to be powered on and ready for user input prior to connecting the mini DVI to video adapter with the s video already connected to it, and to the TV. Once I did it this way, it worked fine. I just thought I'd share this.

Maybe you are looking for

  • Error upgrading identity manager from 6.0 to 7.1 - help!!!

    Hi all, When upgrading from 6.0 to 7.1, I get error below when i am trying to access the approval form by going to workitems->approval->click on one of the items in the inbox. Throws a nullpointer exception...see below.... Alex and other experts pls

  • IMac G5 (iSight) First Impressions

    Well, I got my iMac G5 (iSight) from Apple yesterday. It really looks unbelievable. I'm surprised at how they can get all that power into such an elegant look and design. Ok, here is what I think so far. When I got it out of the box, hooked it up in

  • "Kyle's iPod could not be syncd.  The required file is missing."

    I'm using itunes 7.3.1.3 and I just bought a whole bunch of video podcasts. I went to update my ipod and I got an itunes error message that said "Kyle's iPod could not be syncd. The required file is missing." and also a windows xp error bubble saying

  • SAP MDM - Staffing Issues

    Hi, I'm currently in charge of recruiting for experience MDM people for a Global BW programme, although I'm struggling to find the people.  I've been told by a very Senior BW guy that I will struggle and the only place to find the people is within SA

  • Debugging BPEL process in 10.1.3.1

    Hi, Does anyone know more about debugging features in BPEL 10.1.3.1? If I try to run/debug a BPEL process, it asks for 'Default Run Target' and I do not know what this is - any help? Thanks!