0

Массив

Если вначале массива мы пишем int[]. Зачем после объявления new int [] мы опять пишем тип данных int???

22nd Jul 2018, 1:51 PM
Виталий
Виталий - avatar
1 Answer
+ 4
While int is already specified when declaring the variable, the compiler does not automatically assume that whatever instance of the type created by 'new' belongs to the declared data type. Consider class A and class B where B inherits from A. This makes it possible to do: A obj = new B();
22nd Jul 2018, 2:00 PM
Hatsy Rei
Hatsy Rei - avatar