• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

A Error using array and need explaination why?  RSS feed

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any ideas why I'm having this error


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 51
at card.Deck.<init>(Deck.java:27)
at card.MainDriver.main(MainDriver.java:8)


nothing at main but still why ?


 
Bartender
Posts: 1464
32
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jin Otanashi wrote:any ideas why I'm having this error


None whatsoever, I'm afraid, as there appears to be much more to your program than you're posting. If you will post the whole thing, maybe someone can help.
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code is long :


there is a enum as you know suit and value which is the number 1-9, j q,k and A. and Clubs, Diamonds, Hearts, Spades.

 
lowercase baba
Posts: 12745
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
are you sure this is correct?

it just looks...wrong.
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

fred rosenberger wrote:are you sure this is correct?

it just looks...wrong.



Support to be 52?
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the main where error indicate
 
Stevens Miller
Bartender
Posts: 1464
32
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred has you on the right track. As you have four suits and thirteen values, how many times will this line execute?

And, on the last execution, what number is stored in index?
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stevens Miller wrote:fred has you on the right track. As you have four suits and thirteen values, how many times will this line execute?

And, on the last execution, what number is stored in index?


by the numbers of suit and value player one and player two have
the numbers of card which is 0-51 or 1-52 in the index
 
fred rosenberger
lowercase baba
Posts: 12745
51
Chrome Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The number of cards is 52.
The array has to be defined to hold 52 cards.
An array defined to hold 52 elements will use indexes 0 - 51.
 
jin Otanashi
Ranch Hand
Posts: 123
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

fred rosenberger wrote:The number of cards is 52.
The array has to be defined to hold 52 cards.
An array defined to hold 52 elements will use indexes 0 - 51.


I just figure out thank so much fred
 
Are we home yet? Wait, did we forget the tiny ad?
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!