Like Miga stated, lines 7 and 8 expect command line arguments to be
passed to the program in order for it to function.  You're getting an
error because the arguments are empty when your code attempts to
access those values.  You can't really iterate over an
empty/non-existent/zero-length array.  If you do what Miga says like
so:

a...@compy:~/miscProgging$ java Deal 2 3
[2 of diamonds, 8 of clubs, 9 of spades]
[ace of clubs, king of spades, 9 of diamonds]

you should be good.  I would also put some error code in there to
catch such a problem.  As a best practice you should check all user
(and non-user/computer) input to your program.

-Adam

On Thu, Apr 23, 2009 at 7:45 AM, miga <[email protected]> wrote:
>
>
>
> On Apr 23, 1:31 pm, John Joseph <[email protected]> wrote:
>> Hi
>>      I am working on “Java collections  Frame Work “ chapter .  While I am 
>> trying out “List-ArrayList-Deal “ I am getting
>> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
>>         at listarraylistdeal.Deal.main(Deal.java:7)
> You should pass parameters to the project, say 5 6, to get it work
> correctly. Study the code, you see that it requires a numHands and a
> cardsPerHand which are retrieved from the arguments passed to the
> class. Here with 5 6 you will get 5 hands and 6 cards per hand.
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to