I am populating a list via an sql query, each element of the list consist of the entire row of data from the db. I want to reference the data by column, however when I use list.get I get something like this. [[Ljava.lang.Object;@76c886]. Do I need to use something other then a list?
No. The list is fine. It's just that when you say you "get" that data, what you are actually saying is that when you use System.out.println() to write it to the console, that's what you see, right?
If it's an array, then just cast the result of the list's get() method to Object -- an array of objects -- and start using the array. What you saw when you printed the array was the output of the array's toString() method, which just prints the type of the array and an internal number. That's irrelevant to how you would actually use the array.
Joined: Oct 22, 2009
Thanks to everyone for your replies.
I ended up using the followng:
Object cols = (Object)results.get(0);
String a = (String)cols;
while populating the list you are storing column values in some object and in turn that object in list, is it? Then does that object has getter methods ? If it is not the case, then I don't understand that how in single list element you are populating multiple column of database?