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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:13:45+00:00 2026-06-03T04:13:45+00:00

(Redefinition of the method public Collection<String> values(); ) I have a Map contained in

  • 0

(Redefinition of the method

public Collection<String> values();

)

I have a Map contained in another Map, so its something like that:

Map<String,Map<String,String>> centralMap

(the intern map is subjectGradeMap)
I want now to use this method:

public Collection<String> values()

to get a collection with all the values of the map. I tried:

Collection<String> returncoll = centralMap.values().values();

but it didn’t work. Tried this too:

Collection<Map<String,String>> collec = centralMap.values();
Collection<String> returncollection = collec.values(); 

but in vain :-S

That problem was solved thanks!
Now i would like to ask you if you have an idea, how should I implement the Iterator method?

/**
* Returns an Iterator, that pass through all the entries of the map. If
* something changes in the map, when it is being passed through all its'
* entries by the Iterator, we can't determinate the behaviour that will
* happen..
*
* @return An Iterator that pass through all entries. Every entry will be
*         returned as String-Tripel with its' three Elements row, column
*         and value.
*/
@Override
public Iterator<Entry> iterator() {
return null;
}

Do you have an idea?

the Entry class is the following one, (implemented in the interface that I use to create my objects of TrueStringMap2D:

final class Entry
    {       
       /** First Key. */
        private final String key1;

       /** Second Key. */
        private final String key2;

       /** Value. */
        private final String value;

       /** Ctor for a tripel.
        * @param key1 1st key.
        * @param key2 2nd key.
        * @param value Value.
        */
        public Entry(final String key1, final String key2, final String value)
        {
            this.key1 = key1;
            this.key2 = key2;
            this.value = value;
        }

        public String getFirstKey()
        {
            return key1;
        }

        public String getSecondKey()
        {
            return key2;
        }

        public String getValue()
        {
                return value;
        }

        @Override public boolean equals(final Object anything)
        {
            if(anything == null)
                return false;
            if(getClass() != anything.getClass())
                return false;
            final Entry that = (Entry)anything;
            return Objects.equals(getFirstKey(), that.getFirstKey())
                   && Objects.equals(getSecondKey(), that.getSecondKey())
                   && Objects.equals(getValue(), that.getValue());
        }

        // CHECKSTYLE- Magic Number
        @Override public int hashCode()
        {
            int hash = 7;
            hash = 17 * hash + Objects.hashCode(getFirstKey());
            hash = 17 * hash + Objects.hashCode(getSecondKey());
            hash = 17 * hash + Objects.hashCode(getValue());
            return hash;
        }
        // CHECKSTYLE+ Magic Number

        @Override public String toString()
        {
            return String.format("(%s, %s, %s)", getFirstKey(), getSecondKey(), getValue());
            }

    }

Thankyou for your help!

  • 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-03T04:13:46+00:00Added an answer on June 3, 2026 at 4:13 am

    centralMap.values() returns you a Collection, Collection doesn’t have values(). centralMap.values() essentially returns a list of Maps. So in order to assess each of those maps, you will need to iterate:

    for (Map map : cetralMap.values()) {
        Collection values = map.values();
        // do something with your values here
    }
    

    To build a collection of all values from all the maps contained in centralMap:

    List myGrandList = new ArrayList();
    for (Map map : centralMap.values()) {
        myGrandList.addAll(map.values());
    }
    return myGrandList;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some enum defined like (in header): typedef enum { METHOD, URL, URL_PARAM,
I have a C# library that I'd like to make distributable with a wrapper
I have the following in my Puzzle.h class Puzzle { private: vector<int> puzzle; public:
can somebody explain me about redefinition in C: is it possible to do something
I have a C++ library (Win32) that fills some fields in a web page
I do know that include guards are to prevent redefinition. But does function prototype
I have a ListView in a Windows Form that I bind a list of
When writing a header library (like Boost ), can one define free-floating (non-method) functions
How do you monkey patch a method of a class that is used in
I have the following class public class classB : classA which contains function dostuff

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.