Array out of bounds question

Page 1 of 1

1 Replies - 243 Views - Last Post: 28 February 2016 - 05:23 PM Rate Topic: -----

#1 jckool18   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 8
  • Joined: 27-February 16

Array out of bounds question

Posted 28 February 2016 - 05:06 PM

I am having trouble with a line of code in my program. It is giving me an error that says array out of bounds in my command line argument. Is there anyone that can take a look at this section of code and tell me what I am missing or what I need to add>

    public static void main(String[] args) throws IOException { 
		System.out.println( "\ncommand line arguments:\n");
		for ( int i = 0; i < args.length; i++ ) { 
			String s = args[ i ]; 
			System.out.println( "argument " + i + ": " + s ); 
		}
		try {
		[color="#0000FF"]File file = new File( args[ 0 ] );[/color]
		int intvalue1 = Integer.parseInt( args[ 1 ] );
		System.out.println( "\nintvalue = " + intvalue1);
		int intvalue2 = Integer.parseInt( args[ 2 ] );
		System.out.println( "\nintvalue = " + intvalue2);

			BufferedReader br = new BufferedReader( new FileReader( file ));
			System.out.println( "\nFile opened successfully.");
			br.close(); 
		} catch ( Exception e ) { e.printStackTrace(); 
		}
    	}[color="#FFFF00"][/color]


Is This A Good Question/Topic? 0
  • +

Replies To: Array out of bounds question

#2 andrewsw   User is offline

  • Entwickler
  • member icon

Reputation: 6602
  • View blog
  • Posts: 26,902
  • Joined: 12-December 12

Re: Array out of bounds question

Posted 28 February 2016 - 05:23 PM

Duplicate topic closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1