How can I search through a scanner and divide a String by spaces?

I am trying to construct a store by reading items from a given Scanner. The constructor must repeatedly (until item name is *) read items from the given scanner object and add it to its inventory. BreadLoaf 2.75 25 I need to divide a string like this into "Breadloaf" "2.75", and "25". And then go to the next line and do the same thing until it reads "*" public class Store { private ArrayList inventory; // CONSTRUCTORS /* * Constructs a store without any items in its inventory. */ public Store() { } /* * Constructs a store by reading items from a given Scanner. The constructor * must repeatedly (until item name is *) read items from the given scanner * object and add it to its inventory. Here is an example of the data (that * has three items) that could be entered for reading from the supplied * scanner: */ public Store(Scanner keyboard) { while(keyboard != null){ } }
@vishal_aim not sure how to divide it up

以上就是How can I search through a scanner and divide a String by spaces?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏