Solved

Java's args.length

Posted on 1998-07-14
5
1,857 Views
Last Modified: 2006-11-17
if I give *  as a an argument in command line for a java program, why args.length returns 268? and not 1
ex:
java myProgram *
args.length returns 268??? and not 1

can any body tell me ???? please

I use 1.2beta3 JDK on Windows 95
0
Comment
Question by:hvhemant
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:msmolyak
ID: 1226355
Can't see why it should. Could you supply a code sample.
0
 

Author Comment

by:hvhemant
ID: 1226356
msmolyak,
here is the simple code

class Test{
   public static void main(String args[]){
      System.out.println(args.length());
    }
}
0
 

Author Comment

by:hvhemant
ID: 1226357
msmolyak,
     here is the simple code please ignore the above sample code.

class Test{
        public static void main(String args[]){
           System.out.println(args.length);
         }
     }
0
 

Author Comment

by:hvhemant
ID: 1226358
Edited text of question
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 1226359
Apparently asterisk gets treatead as a wild card so the args array gets populated with the names of the files matching the pattern. I am not sure whether it is a standard feature of JVM. I tried the same in Symantec and it does not seem to do it.

If you want to pass an asterisk, use "*".
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question