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; }

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"

User Gnath
by
8.0k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.