How do I make an array of arrays in Java -


this question has answer here:

i want create program creates deck of cards , have array of cards. each card array holds 2 values, suit , value.

so able card[1] = [1,5] 1 rank of suite , 5 value of card.

it's been long time since have used java project reteach me how program.

thanks in advance help!

int[][] cards = new int[52][2]; 

so cards[0] value of first card, array 2 elements. cards[0][0] suit of first card, example (if suit comes before value).

but consider making array of card objects, , have card object have 2 fields. has advantage of being less confusing (will remember comes first), easier read (cards[0].getsuit() nicer cards[0][0]), , if want add more accessory data, it'll easier having tack on third element array.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -