Somebody, anybody, please help. I have been arguing with this lesson for days. (It seemed to take forever to figure out the main issue) Now I am stuck on the last condition. I have tried everything I could think of (didn't work), tried GOOGLE (apparently I'm too dense to understand that) and I have tried mimicking what I have seen in the other HELP answers (that's where my code sits now - see below).
The last condition is failing with this error:
Error in com/codegym/task/task08/task0814/Solution.java on line 47
cannot find symbol
symbol: class Iterator
location: class com.codegym.task.task08.task0814.Solution
Current code:
public static HashSet<Integer> removeAllNumbersGreaterThan10(HashSet<Integer> set)
{
// write your code here
Iterator <Integer> itr = set.iterator();
while(itr.hasNext())
{
if(itr.next() > 10)
{
itr.remove();
}
}
return set;
}
package com.codegym.task.task08.task0814;
import java.util.HashSet;
import java.util.Set;
/*
Greater than 10? You're not a good fit for us
*/
public class Solution
{
public static HashSet<Integer> createSet()
{
// write your code here
HashSet<Integer> set = new HashSet<Integer>();
set.add(10);
set.add(1);
set.add(11);
set.add(2);
set.add(12);
set.add(3);
set.add(13);
set.add(4);
set.add(14);
set.add(15);
set.add(5);
set.add(16);
set.add(6);
set.add(7);
set.add(8);
set.add(9);
set.add(17);
set.add(18);
set.add(19);
set.add(20);
return set;
}
public static HashSet<Integer> removeAllNumbersGreaterThan10(HashSet<Integer> set)
{
// write your code here
Iterator <Integer> itr = set.iterator();
while(itr.hasNext())
{
if(itr.next() > 10)
{
itr.remove();
}
}
return set;
}
public static void main(String[] args)
{
}
}