Iterator problem, using arrays

I'm trying to creat a main method that will crate an array with size 5 the values of the elements are {4, 7, 3, 0, 1}.
This next part i'm getting a little confused about. I'm trying to creat an iterator for the array and print the array using the iterator.

The errors i'm getting are:
2 Errors found:
Error(1): package v does not exist  ---------->( found on this line  [Iterator iter = new v.iterator();] )
Error(2): cannot find symbol  ---------------->( found on this line   [System.out.println(iter.current);] )
symbol  : variable current
location: interface java.util.Iterator

import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.AbstractCollection;

public class BSTOrderedList<T extends Comparable<? super T>>
  extends AbstractCollection<T>
  implements OrderedList<T> {
  private BinarySearchTreeWithRank<T> bst = new BinarySearchTreeWithRank<T>();
  public BSTOrderedList() {
  public int size() {
    return bst.size();
  public boolean contains(Object x) {
      return true;
      return false;
  public boolean add( T x ) {
      return true;
      return false;
  public boolean remove(Object x) {
    if(bst.find((T)x) != x)
    return true;
      return false;
  public T get( int i ) throws NoSuchElementException {
        return bst.findKth(i);
  public int indexOf( Object obj ) {
      return bst.indexOf((T)obj);
      return -1;
  public Iterator<T> iterator() {
    MyIterator iter = new MyIterator();
    return iter;
  private class MyIterator implements Iterator {
     private Comparable current;
     private int k;
     public MyIterator() {
          current = bst.findKth(++k);
     public boolean hasNext() {
          return bst.findKth(k + 1) != null;
     public Comparable next() {
       return (current = bst.findKth(++k));
     public void remove() {
  public static void main(String[] args) {

    int[] arr = {4, 7, 3, 0, 1};
  BSTOrderedList v = new BSTOrderedList();
  Iterator iter = new v.iterator();
while( iter.hasNext())
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

> iter.current

Iterator does not have such filed
Hi no158,

Did you mean:

Joe P
> new v.iterator();
eliminate new keyword
Iterator iter = v.iterator();

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.