eclipse - How to correctly specify a list in java -


i using eclipse juno , java.

i want create list , store list in list can pass list of lists server side. have tried:

arraylist<t> listaccountandcubs = new arraylist<comparable>(); listaccountandcubs.add(accountid); listaccountandcubs.add(sqldatearchived); 

however, can not values "t" , "comparable" correct. tried "string" not work storing date.

once above correct how set list contain "listaccountandcubs"?

thanks assistance,

glyn

if understand crrectly want have list of strings, , store in list?

list<string> sl = new arraylist<string>(); list<list<string>>sls = new arraylist<list<string>>(); sls.add(sl); sl.add("string 1"); 

the value "t" placeholder type, list generic interface, can take arbitrary object.

if want create list of unspecified types, use

list<?>list = new arraylist<?>(); 

then can add untyped objects it, in case not neccessary.

instead can of course create list of comparables. this:

list<comparable<string>>list = new arraylist<comparable<string>>(); 

Comments