I am using Eclipse ADT to learn Java. I used ADT for an intro to Android course on the MOOC coursera platform. Going through that course, I see that learning Java is needed.
I am working through a java book: JAVA in easy steps by Mike Mcgrath
This lesson is teaching: Passing an argument. The code I have entered in ADT is:
package com.javatutorial.hello;
public class Option {
public static void main ( String[] args ) {
if ( args[0].equals( "-en"))
{
System.out.println( "English option");
}
else if ( args[0].equals( "-es"))
{
System.out.println( "Spanish option");
}
else System.out.println( "Unrecognized option");
}
}
When I run the program I get this exception error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.javatutorial.hello.Option.main(Option.java:5)
So far I have figured out solutions to problems I have run into, but need help for this one. Thank you in advance for your help.