I'm trying to enter a string for example: 1h 2s 3h and store those values in an array for example [0] = (1, h). My code generates a run-time error, can you guys give me some advice. Thanks public void convertArray(String x) { int rank; char suit, rankChar; for(int i = 0; i < cards.length(); i++) { rank == cards.charAt(i); rankChar = cards.charAt(i); suit = cards.charAt(i+1); if (rankChar == 'a') rank == Card.charToRank('a'); Card nextCard; nextCard = new Card(rank,suit); nextCard = enteredHand; } } *charToRank is a switch statement that returns a number
/** Takes a String in the format 1h 2s 3h 10s jc qd, processes it into a vector of Card objects. */ public Vector sortString(String s){ Vector v = new Vector(); //assume string is in format 1h 2s 3h 10s jc qd StringTokenizer st = new StringTokenizer(s, " "); //assume space is separator while (st.hasMoreTokens){ String nextcardstring = st.nextToken(); if (checkData(nextcardstring)) { Card nextcard = new Card(nextcardstring) v.add(nextcard); } }