how to use String []?
I want to store the results of a database query into a series of strings.I tried String [] rowsData;where I wanted something like rowsData.add(thisrow);Of course this syntax is wrong.What is the proper way to do this?Thanks,Ilan
[277 byte] By [
Ilana] at [2007-11-26 12:53:08]

An array's dimension is set when you define it and can not be changed. Either you know the dimension in advance, and create the array correspondingly, or you can use a List, for example an ArrayList, which can grow as needed.
Thanks. I don't yet know the difference between List, ArrayList and Vector, but I suspect any of them will do.
I want to add strings as
rowsData.add(thisrow);
It tells me Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized.
OK, I agree that I would like to tell it that I'm adding strings, but how exactly?
My next line is tmp2 = rowsData.get(0);
which it complains that it can't convert an object to a string. If I tell it that the object IS a string, then will it still complain?
Thanks,
Ilan
Ilana at 2007-7-7 16:43:16 >

> you can also use Vector to store array of results and> retrive., i used to use vectorVectors are pretty outdated. Look into other Collections, such as an [url http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html]ArrayList[/url].