Hi, I have a problem with third task from lesson 8. My solution is not passing test. What can I do? This is a whole source code from my solution:

package com.javarush.test.level08.lesson08.task03;

import java.util.*; public class Solution { public static HashMap<string, string=""> createMap() { HashMap<string, string="">m = new HashMap<string, string="">(); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar"); m.put("Foo", "Bar");

    return m;
}

public static int getCountTheSameFirstName(HashMap<String, String> map, String name)
{
    int j=0;
    Iterator<Map.Entry<String, String>> i = map.entrySet().iterator();
    while(i.hasNext())
    {
        Map.Entry<String, String>pair = i.next();
        Object val = pair.getValue();
        if(val == name)
        {
            j++;
        }
    }
    return j;
}

public static int getCountTheSameLastName(HashMap<String, String> map, String familiya)
{
    int j=0;
    Iterator<Map.Entry<String, String>> i = map.entrySet().iterator();
    while(i.hasNext())
    {
        Map.Entry<String, String>pair = i.next();
        Object key = pair.getKey();
        if(key == familiya)
        {
            j++;
        }
    }
    return j;

}

}

asked 09 Sep, 16:30

DoxPl's gravatar image

DoxPl
11
accept rate: 0%

edited 09 Sep, 16:34

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×52
×39
×17

Asked: 09 Sep, 16:30

Seen: 106 times

Last updated: 09 Sep, 16:34