what will the o/p for this ...
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi friends;
Can u explain why the o/p of this program is like this:
class Test{
public static void main(String args[]){
for(int nElement = 0 ; nElement < args.length ; nElement++)
{
System.out.println("File: "+args [nElement]);
}
}
}
Can u explain why the o/p of this program is like this:
class Test{
public static void main(String args[]){
for(int nElement = 0 ; nElement < args.length ; nElement++)
{
System.out.println("File: "+args [nElement]);
}
}
}
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
can tell what do you mean by o/p?
thanks.
thanks.
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
If you start a Java program from the command line with a few arguments then the JVM invokes the main method you show in your example, with the parameters in the args. So if you type:
java MyClass able baker charlie
then args[0] is able, args[1] is baker, args[2] is charlie. The loop in your program will print the arguments out on one line each.
Your example includes the word "File:" so I'd guess your program is expecting a list of files as arguments. If a filename includes spaces you'll have to type it in quotes so it is read as one argument and not two or three.
java MyClass "c:\program files\my file.txt"
Is that the kind of thing you were asking? Sorry if I backed up over stuff you already knew.
java MyClass able baker charlie
then args[0] is able, args[1] is baker, args[2] is charlie. The loop in your program will print the arguments out on one line each.
Your example includes the word "File:" so I'd guess your program is expecting a list of files as arguments. If a filename includes spaces you'll have to type it in quotes so it is read as one argument and not two or three.
java MyClass "c:\program files\my file.txt"
Is that the kind of thing you were asking? Sorry if I backed up over stuff you already knew.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Welcome to JavaRanch, arun!
Can u explain why the o/p of this program is like this:
What is the output? And do you have any ideas on why it might be that way?
can tell what do you mean by o/p?
Namaste, "o/p" likely means "output".
[ July 04, 2003: Message edited by: Dirk Schreckmann ]
Can u explain why the o/p of this program is like this:
What is the output? And do you have any ideas on why it might be that way?
can tell what do you mean by o/p?
Namaste, "o/p" likely means "output".
[ July 04, 2003: Message edited by: Dirk Schreckmann ]
| You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad? The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










