Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3236972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:41:02+00:00 2026-05-17T17:41:02+00:00

In this sample(it’s from the Oracle Site ) : // Notify all listeners that

  • 0

In this sample(it’s from the Oracle Site) :

// Notify all listeners that have registered interest for
// notification on this event type.  The event instance 
// is lazily created using the parameters passed into 
// the fire method.

protected void fireFooXXX() {
 // Guaranteed to return a non-null array
 Object[] listeners = listenerList.getListenerList();
 // Process the listeners last to first, notifying
 // those that are interested in this event
 for (int i = listeners.length-2; i>=0; i-=2) {
     if (listeners[i]==FooListener.class) {
         // Lazily create the event:
         if (fooEvent == null)
             fooEvent = new FooEvent(this);
         ((FooListener)listeners[i+1]).fooXXX(fooEvent);
     }
 }
}

What does this

listeners[i]==FooListener.class

Comparison do? It throws me off a bit, since it seems its comparing an instance of a class to a type of class. I would could understand it if it said something like

listeners[i].getClass() == Foolistener.class

But it doesn’t…Can someone enlighten me here? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:41:02+00:00Added an answer on May 17, 2026 at 5:41 pm

    Because that’s what the documentation of getListenerList() says it does.

    public Object[] getListenerList()

    Passes back the event listener list as
    an array of ListenerType-listener
    pairs. Note that for performance
    reasons, this implementation passes
    back the actual data structure in
    which the listener data is stored
    internally! This method is guaranteed
    to pass back a non-null array, so that
    no null-checking is required in fire
    methods. A zero-length array of Object
    should be returned if there are
    currently no listeners. WARNING!!!
    Absolutely NO modification of the data
    contained in this array should be made
    — if any such manipulation is necessary, it should be done on a copy
    of the array returned rather than the
    array itself.

    The array is in pairs of Type and Instance. So index zero is the class (or superclass) of the actual listener found at index 1, index 2 is the class of the actual listener at 3, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sample text, which is retrieved from the class name on an
I have this sample code, that works: <video src=./ellen.ogv width=320 height=240 type='video/ogg; codecs=theora, vorbis'
I have this sample configuration in my assemblyinfo file. // You can specify all
I have a this aspx-code: (sample) <asp:DropDownList runat=server ID=ddList1></asp:DropDownList> With this codebehind: List<System.Web.UI.WebControls.ListItem> colors
well i have this messages table with sample values like these: msg_id recipient_id read
From this sample code from MSDN http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx The hash code for abc is: 536991770
I have this sample code which generates the following warning (VS2008 compiler with SP1):
I have this sample code: struct A { bool test() const { return false;
I have this sample string: Image: SGD$45.32 SKU: 3f3f3 dfdfd grg4t BP 6yhf Pack
Imagine this sample java class: class A { void addListener(Listener obj); void removeListener(Listener obj);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.