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

  • Home
  • SEARCH
  • 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 8065733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:45:37+00:00 2026-06-05T11:45:37+00:00

I´m trying to extend a Java ArrayList to support events as described in this

  • 0

I´m trying to extend a Java ArrayList to support events as described in this example:
http://www.exampledepot.com/egs/java.util/CustEvent.html

The problem is that java is reporting that ‘Cannot make a static reference to the non-static type MyEvent’ in the following line:

public interface MyEventListener extends EventListener {
    public void myEventOccurred(MyEvent evt);
}

I think that is something related to Generics, but I really don´t know how to solve this issue. Does anybody can help me?

Here is the full source of what I´m trying to do:

public class ArrayList<E> extends java.util.ArrayList<E> {

    private static final long serialVersionUID = 1L;

    // Declare the event. It must extend EventObject.
    public class MyEvent extends EventObject {

        private static final long serialVersionUID = 1L;

        public MyEvent(Object source) {

            super(source);
        }
    }

    // Declare the listener class. It must extend EventListener.
    // A class must implement this interface to get MyEvents.
    public interface MyEventListener extends EventListener {
        public void myEventOccurred(MyEvent evt); //Error occurs here
    }
}
  • 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-06-05T11:45:39+00:00Added an answer on June 5, 2026 at 11:45 am

    There’s a more complex solution and a simpler one. The simpler one: Don’t use inner classes or interfaces here; there’s simply no need, and they only complicate matters. As an aside, why is your class given the same name as the core class? If that compiles (and I’m guessing it does), it’s highly confusing to all.

    Edit: and in your link, none of those classes or interfaces are meant to be inner, so you’ve transcribed it wrong. Again, put each class and interface in its own file. There are times when you will want to use inner classes, but this is most definitely not one of them.

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

Sidebar

Related Questions

I'm looking at some code with this form: 1 package com.stackoverflow.java.questions; 2 import java.util.ArrayList;
I'm trying to put together a simple RSS reader, and found code on http://www.ibm.com/developerworks/opensource/library/x-android/
I am trying to use org.apache.commons.collections.CollectionUtils in Android. The sample is below import java.util.ArrayList;
hi I am trying to fetch data from link as given below http://abovestress.com/app_stress/fetch_all_detail.php?task=fetchtimefromdateanduserid&track_date=2011-08-09&tracker_user_id=374 but
I'm trying to use Android Application class (MyApplication.java) for store data in some ArrayList
I am trying to create a memory game in Java. Something like this, but
I am having an issue with parsing the following website: http://www.x-rates.com/d/USD/table.html I am very,
I'm trying to pass a java.util.Stack object from an Activity to another in an
Trying to serialize and send Lot object to socket. Getting error: java.io.NotSerializableException: com.server.ClientServiceThread Why?
I am just trying to understand the extends keyword in Java Generics. List<? extends

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.