Re: problem...sorry my first time with java



NewsFree wrote:

public class cl_gm {
public static void main(String[] args) {
int num = Integer.parseInt(args[0]);
[...snip...]

java.lang.ArrayIndexOutOfBoundsException: 0
at cl_gm.main(cl_gm.java:3)
Exception in thread "main"

Thankyou for any suggestion!

You need to pass the month number as an argument, like this for the
length of March:

java cl_gm 3
31

If you just run

java cl_gm

the String array passed to the main method as args[] will be empty, so
args[0] will be outside the array, and the
ArrayIndexOutOfBoundsException is thrown because of this.

You may wish to familiarise yourself with the javadoc for the exception
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ArrayIndexOutOfBoundsException.html>

--
Rob Skedgell <rob+news@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
All posts made via GoogleGropes killfiled, sorry.
GnuPG/PGP: 7DA3 1579 C0DD 8748 C05A B984 E2A2 3234 D14B 6DD7

.



Relevant Pages