Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

array index out of bounds error

883540Sep 12 2011 — edited Sep 12 2011
I typed up this sample program from a tutorial book:

package nameTest;

public class PrintName {

public static void main(String[] args) {
String firstName = args[0];
String lastName = args[1];
System.out.println(firstName + " " + lastName);
}

}

However, when I try to run it, I get this error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at nameTest.PrintName.main(PrintName.java:6)

This code used to work before I updated to Java 6u26 (my previous version was J2SE 1.5 u6).

Can anyone help me?
This post has been answered by 796440 on Sep 12 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 10 2011
Added on Sep 12 2011
4 comments
1,302 views