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 9192151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:51:16+00:00 2026-06-17T20:51:16+00:00

I have a class and function defined as the following: public class Site {

  • 0

I have a class and function defined as the following:

public class Site {
    public EnumSet<?> contents;

    public void determineStates(Site a, Site b) {
        this.contents.clear();
        this.contents.addAll(a.contents);
        this.contents.addAll(b.contents);
        a.contents.removeAll(b.contents);
        this.contents.removeAll(a.contents);
    }
}

For both addAll operations, Eclipse is giving me the following error message:

The method addAll(Collection<? extends capture#6-of ?>) in the type AbstractCollection<capture#6-of ?> is not applicable for the arguments (EnumSet<capture#7-of ?>)

Essentially I need some form of Enum generics and I have just been frustrated with what appear to be limitations. I have a number of Enum types that are incompatible but I desire some container that can hold any type.

I recognize that in this code there is no way to be certain that a, b, and contents are all of the same Enum type, however in actual implementation this should not be problematic.

Any thoughts and possible methods to address my generic Enum problem would be valuable and I would be immensely grateful for your help. 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-06-17T20:51:17+00:00Added an answer on June 17, 2026 at 8:51 pm

    The Site class should be generic:

    public class Site<E extends Enum<E>> {
        public EnumSet<E> contents;
    
        public void determineStates(Site<E> a, Site<E> b) {
            this.contents.clear();
            this.contents.addAll(a.contents);
            this.contents.addAll(b.contents);
            a.contents.removeAll(b.contents);
            this.contents.removeAll(a.contents);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a function defined like this: class Foo() { public: void bar(MyClass*
I have this user defined function. public partial class UserDefinedFunctions { static int i;
I have the following function defined inside my linked list class. The declaration in
I have an inline member function defined under class MyClass int MyClass::myInlineFunction(); This function
I have code as following: Public Class xxxSvcHostFactory Inherits ServiceHostFactory Protected Overrides Function CreateServiceHost(ByVal
Providing that I have the following on: TeamGamesDao Class: public function listOfTeams() { $select
I have defined the following class: class Action { public: Action(){ _bAllDone = false;
I have an exception handler defined as following in a Spring controller: @ExceptionHandler(Customized4ExceptionHandler.class) public
I have the following model defined in .NET: Public Class Request <Key()> Public Property
I have a class: function RustEditor() { this.init = function() { var saveButton =

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.