• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to take a series of string from command line?  RSS feed

 
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?
 
Rancher
Posts: 42975
76
  • 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??
 
Sheriff
Posts: 21201
87
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: 42975
76
  • 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?
 
Marshal
Posts: 57239
175
  • 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

 
Your mind is under my control .... your will is now mine .... read this tiny ad
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!