Re: problem...sorry my first time with java
- From: Rob Skedgell <nospam@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 19 Mar 2006 21:49:36 +0000
NewsFree wrote:
public class cl_gm {[...snip...]
public static void main(String[] args) {
int num = Integer.parseInt(args[0]);
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
.
- References:
- problem...sorry my first time with java
- From: NewsFree
- problem...sorry my first time with java
- Prev by Date: Sockets and Selectors -- Is Data One Way?
- Next by Date: Re: problem...sorry my first time with java
- Previous by thread: Re: problem...sorry my first time with java
- Next by thread: Re: problem...sorry my first time with java
- Index(es):
Relevant Pages
|