• Post Reply Bookmark Topic Watch Topic
  • New Topic

Splitting a string with multi-spaces  RSS feed

 
Khusbu Sinha
Ranch Hand
Posts: 117
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string of alphabets with a space between each alphabet. I need to split this string by spaces. I got the following output:

String array after split:[Ljava.lang.String;@fd5d74
String array after split:[Ljava.lang.String;@1d1465b



from this code:



Please suggest the correct method to get the desired String array as output.
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That has nothing to do with splitting. I think you are doing the  splitting correctly. That is happening because arrays don't have an overridden toString() method. Try
 
Khusbu Sinha
Ranch Hand
Posts: 117
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. This helped.
 
Campbell Ritchie
Marshal
Posts: 56593
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pleasure
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!