asked 195k views
24 votes
What is wrong with each of the following code segments? int[] values; for (int i = 0; i < values.length; i++) { values[i] = i * i; }

asked
User Domager
by
7.5k points

1 Answer

5 votes

Answer:

values have been declared but not initialized nor allocated memory. So you are not allowed to use "values.length"

answered
User Gnath
by
8.0k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.

Categories