• Post Reply Bookmark Topic Watch Topic
  • New Topic

need some array help  RSS feed

 
Naru Narusegawa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've been trying to convert my array list to a string array but I've ended up getting "[Ljava.lang.String;@13a99b9a" printed and I'm not sure why. Can someone help me out please thanks. (i print the array list and it does the job, it just fails on the convert)

 
Carles Gasques
Ranch Hand
Posts: 199
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The printed output is correct and is the object reference.
Is an array [ of strings Ljava.lang.String; with the object reference @13a99b9a
If you would to print the strings in the array you have to iterate it.


Cheers,
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words..

You have a box of stuff. When you say "print it", it prints out information about the box, rather than information on the individual contents of the box.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the ranch Naru.
 
Rafael Prado Oliveira
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carles Gasques wrote:Hi,

The printed output is correct and is the object reference.
Is an array [ of strings Ljava.lang.String; with the object reference @13a99b9a
If you would to print the strings in the array you have to iterate it.


Cheers,


Hello

it will be easier if you you use the FOR (over an iterator), and inside it you manipulate the iterable object(in your case a string) as you need.
 
Naru Narusegawa
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh ok, I get what's happening now. But so now all this is in my model class and I want to use this array list and insert the data into a combo box in my view class, how do I do this?

Do I still turn the array list into a string array and iterate that into the combo box?

Thanks
 
Rafael Prado Oliveira
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naru Narusegawa wrote:Oh ok, I get what's happening now. But so now all this is in my model class and I want to use this array list and insert the data into a combo box in my view class, how do I do this?

Do I still turn the array list into a string array and iterate that into the combo box?

Thanks


Swing or JSP?
 
Mansukhdeep Thind
Ranch Hand
Posts: 1163
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds more like apache struts to me. Is that so Naru?
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Naru Narusegawa wrote:I want to use this array list and insert the data into a combo box in my view class, how do I do this?

Do I still turn the array list into a string array and iterate that into the combo box?


That depends on whether your "combo box" has a constructor, or setter, which takes a List<String> or a String[]. A "combo box" could be one of many things (as Mansukhdeep Thind tried to suggest) so we would need to know which it is.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!