Solved

finding the number of arguments passed in through the command prompt

Posted on 2001-07-05
1
217 Views
Last Modified: 2011-09-20
How Do I get the Number of total arguments that is passed in at the command prompt.

example..

c:\java javaprogram first second third

I want it to return in this example 3 because there are three arguments.

Thank You.
0
Comment
Question by:selhamawy
1 Comment
 
LVL 5

Accepted Solution

by:
mattyk earned 50 total points
ID: 6257661
   public static void main (String args[]) {
        System.out.println(args.length);
    }

should do the trick


basically args.length is what you are looking for

-matty
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to add new optional parameter to JSP 1 49
Java exception bubble up 2 21
Java program running SQL query 5 37
hashmap order 17 37
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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

828 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