Can someone tells my what is wrong?

public class Solution {

public static HashSet<Integer> createSet()
{
    HashSet<Integer> set = new HashSet<Integer>();

    int[] licz={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

    for(Integer liczba : licz)
    {
        set.add(liczba);
    }
    return set;
}

public static HashSet<Integer> removeAllNumbersMoreThan10(HashSet<Integer> set)
{
    for(Integer nazwa : set)
    {
        if(nazwa>10) set.remove(nazwa);
    }
    return set;
}

}

asked 28 Mar, 18:37

MasterOwo's gravatar image

MasterOwo
1
accept rate: 0%


This code passed testing:

public static HashSet<integer> createSet() { //add your code here HashSet<integer> set = new HashSet<integer>(); for (int i = 0; i<20; i++){ set.add(i); } return set; }

public static HashSet<Integer> removeAllNumbersMoreThan10(HashSet<Integer> set)
{
    //add your code here
    Iterator<Integer> iterator = set.iterator();
    while (iterator.hasNext()){
        int q = iterator.next();
        if (q > 10) iterator.remove();
    }
    return set;
}
link

answered 08 Oct, 22:09

MrBlick's gravatar image

MrBlick
1
accept rate: 0%

This code passed testing:

  public static HashSet<Integer> createSet()
{
    //add your code here
    HashSet<Integer> set = new HashSet<Integer>();
    for (int i = 0; i<20; i++){
        set.add(i);
    }
        return set;
}

public static HashSet<Integer> removeAllNumbersMoreThan10(HashSet<Integer> set)
{
    //add your code here
    Iterator<Integer> iterator = set.iterator();
    while (iterator.hasNext()){
        int q = iterator.next();
        if (q > 10) iterator.remove();
    }
    return set;
}
link

answered 08 Oct, 22:10

MrBlick's gravatar image

MrBlick
1
accept rate: 0%

Your answer
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:

×53
×20
×13

Asked: 28 Mar, 18:37

Seen: 328 times

Last updated: 08 Oct, 22:10