View Full Version : [SOLVED] Exception in thread "main" java.util.NoSuchElementException

December 19th, 2008, 09:14 PM
Any clues to what I am doing wrong??

import java.io.*;

import java.util.*;

public class a083
static BufferedReader keyboard = new
BufferedReader(new InputStreamReader(System.in));

public static void main(String[] args) throws IOException
int[] list = new int[20];

IntClass length;

int removeItem;

StringTokenizer tokenizer;

System.out.println("Enter 10 numbers seperated by a space");

tokenizer = new StringTokenizer(keyboard.readLine());

for(int i = 0; i < 12; i++)
list[i] = Integer.parseInt(tokenizer.nextToken());

length = new IntClass(12);

print(list, length.getNum());

System.out.print("Enter the number to remove: ");

removeItem = Integer.parseInt(keyboard.readLine());



print(list, length.getNum());

bw@o0$ java a083
Enter 10 numbers seperated by a space
3 4 5 6 1 2 7 8 9 10
Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(StringTokenize r.java:332)
at a083.main(a083.java:28 )

December 19th, 2008, 09:19 PM
I really like posting on this forum because 9 time out of 10 as soon as I post it I figure out the answer!!!LOL Take a look if you like...But I fixed it....

How do I mark a thread as solved??

December 19th, 2008, 09:39 PM
How do I mark a thread as solved??
Go to Thread Tools at the top of the thread.