?
Solved

Java's args.length

Posted on 1998-07-14
5
Medium Priority
?
1,881 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 100 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month13 days, 2 hours left to enroll

777 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