Solved

Java's args.length

Posted on 1998-07-14
5
1,865 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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
spring jars download 1 68
maven module vs maven project 3 112
What's wrong with this code? 4 45
using executorService 3 19
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

732 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