• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String.split() with null values

 
O. Ziggy
Ranch Hand
Posts: 430
Android Debian VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The output of the above is : : : : bb

What exactly happens when the split() does a split but there is nothing in between the split as in the above example.
Is the value (in the array) classed as null or an empty string or something else?

Thanks
 
John Stark
Ranch Hand
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the Strings were null then printing them out would produce 'null' for each String. Doing

gives 'true', so yes the elements of the array are indeed empty strings.

John
 
O. Ziggy
Ranch Hand
Posts: 430
Android Debian VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wasnt actually expecting the empty strings. I thought the contents of the array would be {bb}
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic