Jump to content

Java HW help with error messages

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
//TestListMenu

//Nick Stoner Oct 31, 2008


import list.*;

import java.io.*;


//Tests list by user input via menu options

//

public class TestListMenu

{

	public static void main(String[]args)throws IOException

	{

		List theList=new LinkedList();

	

		while(true)

		{

			printMenu();

			System.out.println("Execute which option?");

			int choice=userInput();

			if(choice==9)

				break;

			processChoice(choice,theList);

		System.out.println("Current list: "+theList.toString());

		}

	}

	

		//post: returns users menu choice

		public static int userInput()throws IOException

		{

			InputStreamReader reader=new InputStreamReader(System.in);

			BufferedReader keyReader=new BufferedReader(reader);

		

			String line=null;

			int choice=0;

			while(choice==0)

				{

				try

					{

					line=keyReader.readLine();

					if(line.equals(""))

						break;

					choice=new Integer(line);

					}

				catch(NumberFormatException ex)

					{

						System.out.println(line+" is not a valid menu choice.");

					}

				}

				return choice;

		}

		

		// post:  prompts for and reads in an int to use for an Index

     	//        in testing List methods, returns that int

      public static int  getIndex() throws IOException

      {

      	InputStreamReader indexReader=new InputStreamReader(System.in);

			BufferedReader indexKeyReader=new BufferedReader(indexReader);

			

			String indexLine=null;

			int indexChoice=0;

			while(indexChoice==0)

			{

				indexLine=indexKeyReader.readLine();

				if(indexLine.equals(""))

				{

					System.out.println("Please enter an integer");

				}

				indexChoice=new Integer(indexLine);

			}

			return indexChoice;	

      }

	  

      //post:  prompts for and reads in an Integer to use for an Element

      //       in testing List methods, returns the Element

      public static Integer getElement() throws IOException

      {

      	InputStreamReader elementReader=new InputStreamReader(System.in);

			BufferedReader elementKeyReader=new BufferedReader(elementReader);

			

			String elementLine=null;

			Integer elementChoice=new Integer(0);

			while(elementChoice==0)

			{

				elementLine=elementKeyReader.readLine();

				if(elementLine.equals(""))

				{

					System.out.println("Please enter an integer");

				}

				elementChoice=new Integer(elementLine);

			}

			return elementChoice;

		}

	

		//post: prints menu options

		public static void printMenu()

		{

			System.out.println("Test Stack operations: "

									+"\n1) add an integer to the list at index #_"

									+"\n2) remove the integer at index #_ from the list"

									+"\n3) find out if the list contains a number"

									+"\n4) get size of the list"

									+"\n5) tell whether the list is empty or not"

									+"\n6) tell what is at index #_"

									+"\n7) set a new integer at index #_"

									+"\n8) tell what index # _ is at"

									+"\n9) quit");

		}

	

		//post: do chosen operation on theStack and print results

		public static void processChoice(int choice,List theList)

		{

			if(choice==1)//add

			{

				Integer element=getElement();

				int index=getIndex();

				theList.add(index,element);	

			}

			else if(choice==2)//remove

			{

				int index=getIndex();

				theList.remove(index);

			}

			else if(choice==3)//find

			{

				int index=getIndex();

				theList.contains(index);

			}

			else if(choice==4)//size

			{

				System.out.println("The size is: "+theList.size());

			}

			else if(choice==5)//list empty or not

			{

				System.out.println("Is current list empty? "+theList.isEmpty());

			}

			else if(choice==6)//what is at index#

			{

				int index=getIndex();

				theList.get(index);

			}

			else if(choice==7)//set new integer at index#

			{

				int index=getIndex();

				Integer element=getElement();

				theList.set(index,element);

			}

			else if(choice==8)//what is the index of #_

			{

				Integer element=getElement();

				theList.indexOf(element);

			}

		}

}

Quote

----jGRASP exec: javac -g J:\cs350\TestListMenu.java

TestListMenu.java:114: unreported exception java.io.IOException; must be caught or declared to be thrown
Integer element=getElement();
^
TestListMenu.java:115: unreported exception java.io.IOException; must be caught or declared to be thrown
int index=getIndex();
^
TestListMenu.java:120: unreported exception java.io.IOException; must be caught or declared to be thrown
int index=getIndex();
^
TestListMenu.java:125: unreported exception java.io.IOException; must be caught or declared to be thrown
int index=getIndex();
^
TestListMenu.java:138: unreported exception java.io.IOException; must be caught or declared to be thrown
int index=getIndex();
^
TestListMenu.java:143: unreported exception java.io.IOException; must be caught or declared to be thrown
int index=getIndex();
^
TestListMenu.java:144: unreported exception java.io.IOException; must be caught or declared to be thrown
Integer element=getElement();
^
TestListMenu.java:149: unreported exception java.io.IOException; must be caught or declared to be thrown
Integer element=getElement();
^
8 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.



Ok so those are the errors I'm getting after compiling in jGRASP. I'm not sure why I'm getting this message because the getElement() and getIndex() methods both declare to throw IOExceptions. What is wrong with my code?

Much thanks for any help!

#2
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
figured that out... added declaration at processChoice method... getting some different error messages now at runtime.

#3
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
kinda haphazard posts there, but I was very distracted last night with the election. I got past the compile errors now I'm at runtime errors.

The errors I've been getting are index out of bounds and null pointers, could someone check my code for where I went wrong?

Thanks,
and hopefully Im not back in 10 minutes posting that I found the problem.

We are writing a doubly linked list, here is that.

// list.LinkedList

//Nick Stoner Oct. 31, 2008


package list;

import java.util.Iterator;

import node.DLNode;


// a List is a linear sequence of elements which are ordered by their indexes in the List

// (indexes 0 to size-1), List elements may be added or deleted or viewed by their indexes

public class LinkedList implements List

{

	private DLNode headNode=new DLNode();

	private int size=0;

	

	public LinkedList()

	{

	

	}

	

	// post: return the number of elements in this list

   public int size()

	{

		return size;

	}

	

   // post: returns true if this list is empty, false otherwise

   public boolean isEmpty()

	{

		if(size==0)

			return true;

		else

			return false;

	}

	

 	//post: checks to see if the given index is in range 0.. maxRangeValue

	//			throws IndexOutOfBoundsException if it isn't

	private void checkIndex(int theIndex, int maxRangeValue)throws IndexOutOfBoundsException

	{

		if(theIndex < 0 || theIndex > maxRangeValue)

        throw new IndexOutOfBoundsException("ERROR: Index " + theIndex +

                                       " is not in range 0.." + maxRangeValue);

	}

	

	//post: returns the node at index theIndex if 0 <= theIndex < size()

	// 		returns the head node if theIndex==size

	private DLNode getNodeAt(int theIndex)

	{

		DLNode hopNode = headNode.getNext(); //start at node at index 0

      int i = 0;


      while(i<theIndex)

      {

         hopNode = hopNode.getNext();

         i++;

      }

      return hopNode;

	}

	

	// post: returns the index of the first occurrence of theElement in this list

   //       or returns -1 if theElement is not in this list

   public int indexOf(Object theElement)

	{

		DLNode hopNode=headNode.getNext();

		int i=0;

		

		while(i<size)

		{

			if(hopNode.getElement().equals(theElement))

				return i;

			hopNode=hopNode.getNext();

			i++;

		}

		return -1;

	}

	

   // post: returns true if theElement is in this list (if some element in list equals(theElement))

   //       false otherwise

   public boolean contains(Object theElement)

	{

		DLNode hopNode=headNode.getNext();

		int i=0;

		

		while(i<size)

		{

			if(hopNode.getElement().equals(theElement))

				return true;

			hopNode=hopNode.getNext();

			i++;

		}

		return false;

	}

	

   // pre: 0 <= theIndex <= size()

   // post: adds theElement at position theIndex,

   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex+1 ...size)

   public void add( int theIndex, Object theElement )throws IndexOutOfBoundsException

	{

		if(size!=0&&size-1<theIndex)

					throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);

		DLNode previousNode=theNode.getPrevious();

		DLNode afterNode=theNode.getNext();

		

		DLNode theNewNode=new DLNode(theElement,previousNode,afterNode);

		theNode.setPrevious(theNewNode);

		previousNode.setNext(theNewNode);

		

		size++;

					

	}

	

   // pre: 0 <= theIndex <= size()

   // post: removes the element at position theIndex and returns it,

   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex-1 ...size-2)

   public Object remove(int theIndex)throws IndexOutOfBoundsException

 	{

		if(size-1<theIndex)

			throw new IndexOutOfBoundsException("Index out of bounds");


		DLNode theNode=getNodeAt(theIndex);

		DLNode previousNode=theNode.getPrevious();

		DLNode afterNode=theNode.getNext();

			

		previousNode.setNext(afterNode);

		afterNode.setPrevious(previousNode);

		size--;

		

		return theNode.getElement();				

	}

		 

   // pre: 0 <= theIndex <= size()

   // post: replaces the element at position theIndex with theElement and returns the element that was replaced,

   //       (does not change the size of the list)

   public Object set( int theIndex, Object theElement )throws IndexOutOfBoundsException

	{

		if(size-1<theIndex)

			throw new IndexOutOfBoundsException("Index out of bounds");


		DLNode theNode=getNodeAt(theIndex);

		Object oldElement=theNode.getElement();

			

		theNode.setElement(theElement);

		

		return oldElement;

	}

	

   // pre: 0 <= theIndex <= size()

   // post: returns the element at position: theIndex (List is unchanged)

   public Object get( int theIndex )throws IndexOutOfBoundsException

	{

		if(size-1<theIndex)

			throw new IndexOutOfBoundsException("Index out of bounds");


		DLNode theNode=getNodeAt(theIndex);

		Object element=theNode.getElement();

		

		return element;

	}

   

	//post: returns the element as strings

	public String toString()

	{

		int i=0;

		String theString="";

		String theSeperator=" ";

		DLNode hopNode=headNode;

		

		while(i<size)

		{

			theString=theString+theSeperator+hopNode.getElement().toString();

			theSeperator=", ";

			i++;

			hopNode=hopNode.getNext();

		}

		return theString;

	}

	// post: returns an instance of Iterator which can be used to iterate thru the list from position 0..size()-1

   //public Iterator iterator();

} 

here is the node used to link this list

//node.DLNode

//Nick Stoner Oct. 31, 2008


package node;


//a DLNode contains one element of a doubly linked list

public class DLNode

{

	private Object element;

	private DLNode next;

	private DLNode previous;

	

	//post: initiates this to contain theElement and point to theNext and thePrevious

	public DLNode (Object theElement,DLNode thePrevious, DLNode theNext)

	{

		setElement(theElement);

		setPrevious(thePrevious);

		setNext(theNext);

	

	}

	

	//post: initialize this to the empty node

	public DLNode()

	{

		this(null, null, null);

	}

	

	//post: stored theElement in this node

	public void setElement(Object theElement)

	{

		element=theElement;

	}

	

	//post: made thePrevious the previous node before this one

	public void setPrevious(DLNode thePrevious)

	{

		previous=thePrevious;

	}

		

	//post: made theNext the next node after this one

	public void setNext(DLNode theNext)

	{

		next=theNext;

	}

	

	//post: returns element stored in node

	public Object getElement()

	{

		return element;

	}

	

	//post: returns the next node after this one

	public DLNode getNext()

	{

		return next;

	}

	

	//post: returns the previous node

	public DLNode getPrevious()

	{

		return previous;

	}

}

I think that should be all you need.

All I've tried to do so far is an add(via menu in first post) and this is what I get.

Quote

----jGRASP exec: java TestListMenu

Test Stack operations:
1) add an integer to the list at index #_
2) remove the integer at index #_ from the list
3) find out if the list contains a number
4) get size of the list
5) tell whether the list is empty or not
6) tell what is at index #_
7) set a new integer at index #_
8) tell what index # _ is at
9) quit
Execute which option?
1
Please enter the element as an int
12
Please enter the index #
0
Exception in thread "main" java.lang.NullPointerException
at list.LinkedList.add(LinkedList.java:101)
at TestListMenu.processChoice(TestListMenu.java:128)
at TestListMenu.main(TestListMenu.java:22)

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.


#4
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
fixed that, now having trouble at toString()

Quote

----jGRASP exec: java TestListMenu

Test Stack operations:
1) add an integer to the list at index #_
2) remove the integer at index #_ from the list
3) find out if the list contains a number
4) get size of the list
5) tell whether the list is empty or not
6) tell what is at index #_
7) set a new integer at index #_
8) tell what index # _ is at
9) quit
Execute which option?
1
Please enter the element as an int
12
Please enter the index #
0
added 12
Exception in thread "main" java.lang.NullPointerException
at list.LinkedList.toString(LinkedList.java:181)
at TestListMenu.main(TestListMenu.java:23)

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.

// list.LinkedList
//Nick Stoner Oct. 31, 2008

package list;
import java.util.Iterator;
import node.DLNode;

// a List is a linear sequence of elements which are ordered by their indexes in the List
// (indexes 0 to size-1), List elements may be added or deleted or viewed by their indexes
public class LinkedList implements List
{
	private DLNode headNode=new DLNode();
	private int size=0;
	
	public LinkedList()
	{
	
	}
	
	// post: return the number of elements in this list
   public int size()
	{
		return size;
	}
	
   // post: returns true if this list is empty, false otherwise
   public boolean isEmpty()
	{
		if(size==0)
			return true;
		else
			return false;
	}
	
 	//post: checks to see if the given index is in range 0.. maxRangeValue
	//			throws IndexOutOfBoundsException if it isn't
	private void checkIndex(int theIndex, int maxRangeValue)throws IndexOutOfBoundsException
	{
		if(theIndex < 0 || theIndex > maxRangeValue)
        throw new IndexOutOfBoundsException("ERROR: Index " + theIndex +
                                       " is not in range 0.." + maxRangeValue);
	}
	
	//post: returns the node at index theIndex if 0 <= theIndex < size()
	// 		returns the head node if theIndex==size
	private DLNode getNodeAt(int theIndex)
	{
		DLNode hopNode = headNode.getNext(); //start at node at index 0
      int i = 0;

      while(i<theIndex)
      {
         hopNode = hopNode.getNext();
         i++;
      }
      return hopNode;
	}
	
	// post: returns the index of the first occurrence of theElement in this list
   //       or returns -1 if theElement is not in this list
   public int indexOf(Object theElement)
	{
		DLNode hopNode=headNode.getNext();
		int i=0;
		
		while(i<size)
		{
			if(hopNode.getElement().equals(theElement))
				return i;
			hopNode=hopNode.getNext();
			i++;
		}
		return -1;
	}
	
   // post: returns true if theElement is in this list (if some element in list equals(theElement))
   //       false otherwise
   public boolean contains(Object theElement)
	{
		DLNode hopNode=headNode.getNext();
		int i=0;
		
		while(i<size)
		{
			if(hopNode.getElement().equals(theElement))
				return true;
			hopNode=hopNode.getNext();
			i++;
		}
		return false;
	}
	
   // pre: 0 <= theIndex <= size()
   // post: adds theElement at position theIndex,
   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex+1 ...size)
   public void add( int theIndex, Object theElement )throws IndexOutOfBoundsException
	{
		boolean isDone=false;
		while(!isDone)
		{
			if(size==0)
			{
				DLNode theNode=new DLNode(theElement,headNode,headNode);
				isDone=true;
				size++;
				break;
			}	
			if(size-1<theIndex)
				throw new IndexOutOfBoundsException("Index out of bounds");
			DLNode theNode=getNodeAt(theIndex);
			DLNode previousNode=theNode.getPrevious();
			DLNode afterNode=theNode.getNext();
		
			DLNode theNewNode=new DLNode(theElement,previousNode,afterNode);
			theNode.setPrevious(theNewNode);
			previousNode.setNext(theNewNode);
		
			size++;
			isDone=true;
		}		
	}
	
   // pre: 0 <= theIndex <= size()
   // post: removes the element at position theIndex and returns it,
   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex-1 ...size-2)
   public Object remove(int theIndex)throws IndexOutOfBoundsException
 	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		DLNode previousNode=theNode.getPrevious();
		DLNode afterNode=theNode.getNext();
			
		previousNode.setNext(afterNode);
		afterNode.setPrevious(previousNode);
		size--;
		
		return theNode.getElement();				
	}
		 
   // pre: 0 <= theIndex <= size()
   // post: replaces the element at position theIndex with theElement and returns the element that was replaced,
   //       (does not change the size of the list)
   public Object set( int theIndex, Object theElement )throws IndexOutOfBoundsException
	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		Object oldElement=theNode.getElement();
			
		theNode.setElement(theElement);
		
		return oldElement;
	}
	
   // pre: 0 <= theIndex <= size()
   // post: returns the element at position: theIndex (List is unchanged)
   public Object get( int theIndex )throws IndexOutOfBoundsException
	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		Object element=theNode.getElement();
		
		return element;
	}
   
	//post: returns the element as strings
	public String toString()
	{
		int i=0;
		String theString="";
		String theSeperator=" ";
		DLNode hopNode=headNode.getNext();
		
		while(i<size)
		{
			theString=theString+theSeperator+hopNode.getElement().toString();
			theSeperator=", ";
			i++;
			if(headNode==hopNode.getNext())
				break;
			else
				hopNode=hopNode.getNext();
		}
		return theString;
	}
	// post: returns an instance of Iterator which can be used to iterate thru the list from position 0..size()-1
   //public Iterator iterator();
} 


#5
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
changed some things in add and toString
still not working

#6
morefood2001

morefood2001

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,720 posts
Line 179: while(i<size-1)

I have a feeling that your while loop is going out of bounds by 1 too many.

#7
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
I've got a good run of it now. I was getting errors because I was trying to get the sentinel node to give me an element.

Also had some problems at the add. Forgot to set previous and next on first add(my special case)to link the list.

#8
nickstoner

nickstoner

    Newbie

  • Members
  • Pip
  • 9 posts
Here's the fixed, any suggestions? Better style I could use?

ick Stoner Oct. 31, 2008

package list;
import java.util.Iterator;
import node.DLNode;

// a List is a linear sequence of elements which are ordered by their indexes in the List
// (indexes 0 to size-1), List elements may be added or deleted or viewed by their indexes
public class LinkedList implements List
{
	private DLNode headNode=new DLNode();
	private int size=0;
	
	public LinkedList()
	{
	
	}
	
	// post: return the number of elements in this list
   public int size()
	{
		return size;
	}
	
   // post: returns true if this list is empty, false otherwise
   public boolean isEmpty()
	{
		if(size==0)
			return true;
		else
			return false;
	}
	
 	//post: checks to see if the given index is in range 0.. maxRangeValue
	//			throws IndexOutOfBoundsException if it isn't
	private void checkIndex(int theIndex, int maxRangeValue)throws IndexOutOfBoundsException
	{
		if(theIndex < 0 || theIndex > maxRangeValue)
        throw new IndexOutOfBoundsException("ERROR: Index " + theIndex +
                                       " is not in range 0.." + maxRangeValue);
	}
	
	//post: returns the node at index theIndex if 0 <= theIndex < size()
	// 		returns the head node if theIndex==size
	private DLNode getNodeAt(int theIndex)
	{
		DLNode hopNode = headNode.getNext(); //start at node at index 0
      int i = 0;

      while(i<theIndex)
      {
         hopNode = hopNode.getNext();
         i++;
      }
      return hopNode;
	}
	
	// post: returns the index of the first occurrence of theElement in this list
   //       or returns -1 if theElement is not in this list
   public int indexOf(Object theElement)
	{
		DLNode hopNode=headNode.getNext();
		int i=0;
		
		while(i<size)
		{
			if(hopNode.getElement().equals(theElement))
				return i;
			hopNode=hopNode.getNext();
			i++;
		}
		return -1;
	}
	
   // post: returns true if theElement is in this list (if some element in list equals(theElement))
   //       false otherwise
   public boolean contains(Object theElement)
	{
		DLNode hopNode=headNode.getNext();
		int i=0;
		
		while(i<size)
		{
			if(hopNode.getElement().equals(theElement))
				return true;
			hopNode=hopNode.getNext();
			i++;
		}
		return false;
	}
	
   // pre: 0 <= theIndex <= size()
   // post: adds theElement at position theIndex,
   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex+1 ...size)
   public void add( int theIndex, Object theElement )throws IndexOutOfBoundsException
	{
		boolean isDone=false;
		while(!isDone)
		{
			if(size==0)
			{
				DLNode theNode=new DLNode(theElement,headNode,headNode);
				headNode.setNext(theNode);
				headNode.setPrevious(theNode);
				isDone=true;
				size++;
				break;
			}	
			if(size<theIndex)
				throw new IndexOutOfBoundsException("Index out of bounds");
			DLNode theNode=getNodeAt(theIndex);
			DLNode previousNode=theNode.getPrevious();
			DLNode afterNode=theNode.getNext();
		
			DLNode theNewNode=new DLNode(theElement,previousNode,afterNode);
			theNode.setPrevious(theNewNode);
			previousNode.setNext(theNewNode);
		
			size++;
			isDone=true;
		}		
	}
	
   // pre: 0 <= theIndex <= size()
   // post: removes the element at position theIndex and returns it,
   //       (elements formerly at positions theIndex...size-1 are now in positions theIndex-1 ...size-2)
   public Object remove(int theIndex)throws IndexOutOfBoundsException
 	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		DLNode previousNode=theNode.getPrevious();
		DLNode afterNode=theNode.getNext();
			
		previousNode.setNext(afterNode);
		afterNode.setPrevious(previousNode);
		size--;
		
		return theNode.getElement();				
	}
		 
   // pre: 0 <= theIndex <= size()
   // post: replaces the element at position theIndex with theElement and returns the element that was replaced,
   //       (does not change the size of the list)
   public Object set( int theIndex, Object theElement )throws IndexOutOfBoundsException
	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		Object oldElement=theNode.getElement();
			
		theNode.setElement(theElement);
		
		return oldElement;
	}
	
   // pre: 0 <= theIndex <= size()
   // post: returns the element at position: theIndex (List is unchanged)
   public Object get( int theIndex )throws IndexOutOfBoundsException
	{
		if(size-1<theIndex)
			throw new IndexOutOfBoundsException("Index out of bounds");

		DLNode theNode=getNodeAt(theIndex);
		Object element=theNode.getElement();
		
		return element;
	}
   
	//post: returns the element as strings
	public String toString()
	{
		int i=0;
		String theString="";
		String theSeperator=" ";
		DLNode hopNode=headNode.getNext();
		
		while(i<size)
		{
			theString=theString+theSeperator+hopNode.getElement().toString();
			theSeperator=", ";
			i++;
			if(headNode==hopNode.getNext())
			{
				break;
			}
			else
				hopNode=hopNode.getNext();
		}
		return theString;
	}
	// post: returns an instance of Iterator which can be used to iterate thru the list from position 0..size()-1
   //public Iterator iterator();
}