This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a way to explode a string to format the different chars?

 
sabin mash
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on an assignment t hat does not allow arrays or arraylists . I want to take a string of 100 random numbers, that looks like this "23 5 87 48 11 8 31", and format it into 5 columns. These numbers are coming from a tree when the tree is created. normally I would take each random number and put it into an array, put that array into a tostring method using modulus operator to print each array value on each line.

Because I can't use arrays, I need to explode the string, or somehow cut it up into something that's not an array. is this possible in java?

sorry for such a newbie question, thank you in advance.
 
John Jai
Rancher
Posts: 1776
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By explode, I believe you mean separate the numbers in the String. You can wrap the String inside a Scanner and use the Scanner's hasNext() and next() methods to loop and print the numbers in a desired way.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic