Java / Generics -
i hava implemented generic arraylist with
public object[] toarray() { return elementdata; }
to able sort later. when try elements out
arraylist<integer> list = new arraylist<integer>(); list.add(10000); list.add(1000); list.add(100); list.add(10); list.add(1); object[] = list.toarray(); for(object o:a) { system.out.println(a); }
it prints "[ljava.lang.object;@2a139a55" , such things, runtime type must integer here, isn't it?
a typo here:
for(object o:a) { system.out.println(a); }
should be
for(object o:a) { system.out.println(o); }
by way, calling system.out.println(list);
enough here.
Comments
Post a Comment