Hi Parven
The program is not supposed to prompt you for anything: it just shows
the content of the command line.
If you run the program as "java CommandLine foo" it will print "No of
parameters: 1" and it will then write "foo". For "java CommandLine bar"
it will write "No of parameters: 1" and "bar". For "java CommandLine foo
bar": "No of parameters: 2" and "foo" then "bar" on two separate lines.
Hope it helps
Mihai
Le 13/04/2011 09:10, syed shabeer ahmed a écrit :
Hi praveen,
I tried the code and its gives the Correct output , i have added the
code and the sample output as well.
public class CommandLine {
public static void main (String argv[])
{
int length = argv.length;
String myString ="No of parameter:";
System.out.println (myString + length);
for (int i=0; i<length; i++)
{
myString = argv[i];
System.out.println(i + ":" + myString);
}
}
}
// End of Program
-------------------------------------------------
Output
--------------------------------------------------
C:\Documents and Settings\Comp\Desktop>java CommandLine Java is a
good language
No of parameter:5
0:Java
1:is
2:a
3:good
4:language
-----------------------------------------------------------------------------------
Regards
Syed Shabeer Ahmed
On Wed, Apr 13, 2011 at 11:26 AM, Parveen Thakur
<parveenkumar...@gmail.com <mailto:parveenkumar...@gmail.com>> wrote:
HI,
when i run the programm it done not ask me for input as below
,I don't understand wht think i missed
public class CommandLine
{
public static void main (String argv [])
{
int length = argv.length;
String myString = “No. of parameters”r
+ “ on the command line: ”;
System.out.println (myString + length);
for (int i=0; i length; i++)
{
myString = argv[i];
System.out.println
(i + “: ” + myString);
}
}
}
• Input: java CommandLine Java is a good
language.
• Output: No of parameters on the command line: 5
0: Java
1: is
2: a
3: good
4: language.
--
To post to this group, send email to
javaprogrammingwithpassion@googlegroups.com
<mailto:javaprogrammingwithpassion@googlegroups.com>
To unsubscribe from this group, send email to
javaprogrammingwithpassion+unsubscr...@googlegroups.com
<mailto:javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
Regards
Syed Shabeer Ahmed
--
To post to this group, send email to
javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
--
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en