我@Jonny亨利同意,一个简单的ArrayList
documentation查找应该足够在这里,但,万一海报是一个新手,这里的我的答案。
// Your code
ArrayList<Object> obj=new ArrayList<Object>();
ArrayList<Object> obj2=new ArrayList<Object>();
obj2.add(101);//contain core data
obj.add(obj2);//storing obj2 into the obj
// My code: Get 101 from obj2
// Because obj2 is in-scope here, and assuming that you know
// obj2 is not empty...
Object data = obj2.get(0);
// Above, data will be an Integer object due to auto-boxing
// If it is null, auto-unboxing will throw NullPointerException
// If data == null, set dataInt to any value to indicate that.
// Here, I am setting it to -1, assuming -1 is an invalid value
// for your application.
int dataInt = (data != null) ? data : -1;
请参阅'ArrayList's'文档,这是一个简短的谷歌搜索了。 –