84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
java中的数组是否有继承关系呢? String[] 是不是Object[] 的子类呢?
看了@MaxValue 发的链接http://www.zhihu.com/question... 之后, 我好像明白了一点, 数组之间不具有继承关系, 都是由jvm关联某一个特定类直接创建出来的, object[] a = new String[3] 应该是由编译器保证的. 不知道这么理解对不对
走同样的路,发现不同的人生
I don’t know how to deal with this JDK, but it seems that there is an inheritance relationship.
public Object[] get(){ return new Integer[]{}; }
This works fine.
But classes with [] cannot be defined.
No. An array is a collection of objects. Only objects have inheritance relationships
string does inherit object, but it has nothing to do with arrays
It can be understood that there is an inheritance relationship, and String[] instanceof Object[] will return true. But List<String> and List<Object> are two types, which are reflected at compile time and will be erased at runtime.
I don’t know how to deal with this JDK, but it seems that there is an inheritance relationship.
This works fine.
But classes with [] cannot be defined.
No. An array is a collection of objects. Only objects have inheritance relationships
string does inherit object, but it has nothing to do with arrays
It can be understood that there is an inheritance relationship, and String[] instanceof Object[] will return true. But List<String> and List<Object> are two types, which are reflected at compile time and will be erased at runtime.