• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Command line aurgments

 
Ravi Kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a doubt regarding Command Line Aurgments.
I want to print the values which are givin througth the Commandline Aurgments EX:-
Suppose i am giving the values from the promt as
java test abc dcb acb
while giving the one value at prompt, when ever you press the 'sapce' the value should be visible on the screen.
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The command line arguments are stored in the args array that is passed to the main method. They can be accessed like any other array. The program below just prints out all the arguments. Note that args[0] is the first argument - the name of the program is not included.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
though code is correct i guess that's just not what OP wants.. i guess he'd want something more like this
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, gotcha. It was the use of the word 'arguments' that threw me.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like homework assingment to me, and the usual misunderstanding of 'advanced'.

Did someone else mention, that beginners-questions are more often posted to 'advanced' than 'intermediate'?
 
Ravi Kumar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank's for reply,

But you are not getting my Question...
First try to undarstand my point then reply according to that one.

when ever giving the command line aurgments, if i press "SPACE" between the values, the value should be apper in the out put taht time only .
Mean ECHO.
In 'C' or 'C++' we are using the getChar() some ting to get the output at the same time.
suppose if u want to give more than one value from the dos prompt you have to give the 'SPACE' immediately the value should be apper in the propt.
 
Manuel Moons
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you mean you want to read some keyboard input from the console.

You can do that using the System.in object. (It is an inputstream)

something like this

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic