Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个对象:
Object o = new Object[] {0, "key", 1234, "name"};
如何从中获取指定数据?
喜欢:
o[2] //1234
或者
o[1] //"key"
Eclipse 给出错误:
The type of the expression must be an array type but it resolved to Object.
你需要这样定义o:
o
Object [] o = {0, "key", 1234, "name"};
然后,您可以按照您指定的方式访问它。
您可以将其定义为数组: Object[] o = new Object[] {0, "key", 1234, "name"};
Object[] o = new Object[] {0, "key", 1234, "name"};