Results 1 to 3 of 3
  1. #1
    girlet18 is offline Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    Default arguments in command-line

    hello everyone, i am supposed to display all the arguments in command-line but when i try to run this program it will display this error
    Java Code:
    java.lang.ArrayIndexOutOfBoundsException: 0
    
            at commandline.Main.main(Main.java:12)
    
    Exception in thread "main" 
    
    Java Result: 1
    with these codes:
    Java Code:
    package commandline;
    
    public class Main {
        
        public static void main( String[] args ) {
            
            int count;
            
            System.out.println(args.length);
            
            for (count=0;count<args.length;count++);
            System.out.println(args[count]);
        }
    }

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    Remove that semicolon at the end of the for loop line. As the code is now, that is where your for loop ends.

  3. #3
    girlet18 is offline Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Command Line Arguments
    By Nakira in forum NetBeans
    Replies: 10
    Last Post: 02-04-2010, 04:45 PM
  2. Command line arguments help
    By may88 in forum New To Java
    Replies: 8
    Last Post: 12-08-2009, 02:20 PM
  3. Multiple Command Line Arguments
    By turnergirl24 in forum New To Java
    Replies: 4
    Last Post: 12-04-2009, 10:36 PM
  4. [SOLVED] command line arguments using IDE
    By sandeepsai39 in forum New To Java
    Replies: 5
    Last Post: 03-12-2009, 08:19 AM
  5. Printing command line arguments
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-03-2007, 10:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •