How should I go about programming this?
I am programming a certain card game. I have 7 cards in my hand like "7D" is 7 of diamonds. I want to program a method that gives me an ArrayList<String> which gives a list of the cards with the same number like "7H, 7D". I'm stuck on what exactly on how to go about doing it. Does anyone have any suggestions or reference I could use?
Re: How should I go about programming this?
Use the String charAt() method to obtain the '7' from "7D". Then use it to build up the strings you add to the array.
Your code will be much more expressive if you write a Card class to model a card, and not use strings. Strings *can* be used to describe anything: but their generality is their weakness if you are interested in the specific behaviour of cards.