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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:50:17+00:00 2026-05-25T11:50:17+00:00

public interface IPowerList<T> extends Iterable< T > { public int bitFlag(List<T> subseq); } public

  • 0
public interface IPowerList<T> extends Iterable< T > {

public int bitFlag(List<T> subseq);
}

public class PowerList<T> implements IPowerList<T>{

private List<T> originalList;
private Set<Set<T>> powerList= new HashSet<Set<T>>();

@Override
public Iterator<T> iterator() {
    // TODO Auto-generated method stub
    return null;
}

@Override
public int bitFlag(List<T> subseq) {
    // TODO Auto-generated method stub
    return 0;
}

}  

Automatically I was given by Eclipse to implement an override method for iterator.

(1) Is it because I implement an interface that extends from iterable?

(2) My private variables are sets and lists- they have their own iterators, I don’t need to define any new iterator- so what should I do? should I erase the inheritance?

(3) when do we need to define a new iterator? when we define a class that it’s kind of collection for us? but I wonder why, cause we always use a generic collections, that have their own iterators..Can you give me an example?

(4) if I add to a set of sets a new HashSet<T>() will you consider it for adding an empty list or adding new HashSet().add(null) will be consider as an empty list?

  • 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-25T11:50:18+00:00Added an answer on May 25, 2026 at 11:50 am

    (1) Is it because I implement an interface that extends from iterable?

    Yes, you get the iterator() method because your interface extends Iterable. That means that any class that implements your interface must also implement all the methods of Iterable. If you didn’t want that, don’t extend Iterable.

    (2) My private variables are sets and lists- they have their own
    iterators, I don’t need to define any new iterator- so what should I
    do? should I erase the inheritance?

    Your private members aren’t available to consumers of your class, so you need a way to expose those iterators. How you do that is up to you, but doing so through your iterate() method makes a lot of sense.

    (3) when do we need to define a new iterator? when we define a class
    that it’s kind of collection for us? but I wonder why, cause we always
    use a generic collections, that have their own iterators..Can you give
    me an example?

    If you create your own collection that you want to be iterable, but that doesn’t extend a collection that already implements Iterable, then you’ll need to create your own iterator. If you don’t care, then there’s no need, though your consumers might feel differently.

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

Sidebar

Related Questions

public interface ITest { int ChildCount { get; set; } } public class Test
public interface DownloadListener { public void onDownloaded(); } public class DownloadManager { private static
public class simplemocking { public interface IFoo { int foo (); } public void
If we have: public interface Foo{} public class Bar implements Foo{...} Is there a
I have following code public interface IEntity { int Id { get; set; }
i have interface: public interface Inx<T> { T Set(Data data); } simple class with
public interface IBaz { IBar bar { get; set; } } public class Baz
Setup public interface ITable { } public class Company : ITable { public int
FooService.cs : public interface IFooService { int Foo(); } [Export(Foo1, typeof(IFooService))] public class Foo1
public interface Foo { } public class SpecificFoo implements Foo { } public interface

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.