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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:09:01+00:00 2026-06-15T23:09:01+00:00

I’ve been struggling to understand the whole abstract idea behind a custom implementation of

  • 0

I’ve been struggling to understand the whole abstract idea behind a custom implementation of a Set interface in Java. In our lectures we’ve implemented functional sets and even flag sets, both of which appear to be inherently recursive lists with functionalities built precisely for a set implementation.

At the end of the day, objects in the set are simply called from the set with a simple for-each loop even though some custom implementations do not remove objects from the list.

For example, in this functional set mentioned, {1,2,3} is represented as Add 3, Add 2, Add 1, Empty while a remove(2) method called directly after would look like Remove 2, Add 3, Add 2, Add 1, Empty. On what basis does Java then decide if the element is part of the set? Does it work solely on the add() and remove() methods to decide if the object still exists in the set?

I hope I’m being coherent enough.

  • 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-15T23:09:02+00:00Added an answer on June 15, 2026 at 11:09 pm

    In our lectures we’ve implemented functional sets and even flag sets, both of which appear to be inherently recursive lists with functionalities built precisely for a set implementation.

    Those implementions are not likely to be particularly instructive for Java Sets. Java sets are mutable … not functional. Anyway, the general specification of the Java Set API is given by the javadoc for the java.util.Set interface.


    On what basis does Java then decide if the element is part of the set?

    The Set / Collection “contract” requires that it use equals(Object) to determine this. For example, the Collection.contains(Object) method is specified as follows:

    “Returns true if this collection contains the specified element [o]. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)).”

    Different set implementations augment or replace this with the Comparable / Comparator APIs or Object.hashCode(). The details are in the respective implementation class javadocs.

    However, there is no guarantee that a custom Set implementation will obey the contract.


    Does it work solely on the add() and remove() methods to decide if the object still exists in the set?

    Other Set methods (such as contains()) also need to know if an object is a set member … if that is what you were asking.

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

Sidebar

Related Questions

I have been unable to fix a problem with Java Unicode and encoding. The
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.