I have a piece of code-
public class Sudoku {
static int[][] game;
public static void main(String[] args) {
int [][] games= new int[3][3];
Object obj =games;
}
}
My question here is how can the "games" reference variable be assigned to the reference variable of type "Object"? I thought the "ClassCastException" would be thrown at runtime. But the code compiles and runs fine. Isnt the reference variable "games" incompatible to be assigned to an Object reference because of 2 reasons- 1)"games" is the reference to a double dimensional int array, whereas "obj" is the reference to an Object. 2)int is clearly a primitive variable..how can it be assigned to a variable of type object? I am running this in the Intellij IDE.