Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How do I check if an element in an array has been initialized?

Tags:

java

I want to check if a certain element in an array has been initilized, how can I do this?

like image 977
Strawberry Avatar asked Dec 22 '22 21:12

Strawberry


1 Answers

All values in an array are initialised when the array is created.

Initial values may be set explicitly (e.g. X[] xs = {x1, ..., xN};), or default values will be assigned when the array is instantiated.

For an array of objects, the default value of each element will be null; for a boolean array, the value will be false; for an array of byte, char, int, long the value will be 0 and for an array of float or double the value will be 0.0.

like image 99
Armand Avatar answered Dec 24 '22 10:12

Armand