265,694 views
23 votes
23 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; }

User Eligro
by
2.3k points

1 Answer

22 votes
22 votes

Answer:

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

User Ferhan
by
2.9k points