• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to take a series of string from command line?

 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i know to take a series of string from command line??


i know to take it with args[0],args[1] but how to take it has a whole??

i mean if i enter "I AM LEARNING JAVA" in the command line

i want to count the number of times "I" repeats in the sentence
so i can't take args[0],args[1]... so how do i take this full sentence as a single thing in my program?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By enclosing it in double quotes, like this:

Then it'll all end up in args[0] - without the quotes.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply


any other options??
 
Rob Spoor
Sheriff
Pie
Posts: 20753
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Join your parameters into one string:
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any other options?

What else are you looking for that this very simple way of doing things doesn't accomplish?
 
Campbell Ritchie
Sheriff
Posts: 51453
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by yuvraj kotegar:
i can't take args[0],args[1]...


Yes, you can; Rob has already told you how to iterate through the array with a for loop.
 
yuvraj kotegar
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great help guys.. thanks

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic