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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -