Java Question

Object to boolean coversion in Java

For example I have an array

Object[][] array = Object[n][2];

Second row of this array contains an
data, due to:

for (int i = 0; i < array.length; i++){
boolean bool = true;
array[i][1] = bool;

Is it possible to convert an
, which is an object type, back to the

Answer Source

You can use a cast to convert it back to a boolean type. For example, if array is declared as an Object[][] but contains a boolean type, you can do this:

boolean bool = (Boolean) array[0][1];