Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

problem with a nullPointerException

$
0
0
static void displayData (String[] input)
	{
		int limit = 10;
		int[] word = new int[limit];
		for (String a: input)
		{
			int b = a.length();
			word[b]++;
		}
		
		for (int i = 0; i< limit;i++)
			System.out.println("There are "+ word[i] + " words with "+ i+ " characters");
		
	}// end display data method


the error happens with this line
word[b]++;

any help is greatly appreciated
thanks
dale

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>