0

I am trying to create a program that shuffles a deck of cards in character array form. Here is my code. Problem is that it compiles with "illegal start of expression" for the deck array,as well as other errors,and "class, interface, or enum expected" for the hasRemaining method:

public class Blackjack
{
    public static void main(String args[])
{
            char[] deck = new char[]{'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K','A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K','A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'};
            char[] deck2 = new char[52];

            int i = 0;

            while (hasRemaining(deck))
            {

                Random rand = new Random();
                int r = rand.nextInt(52);
                if (deck[r] != '-1')
                {
                    deck2[i] = deck[r];
                    deck[r] = -1;
                    i++;
                }
            }

            System.out.println(deck2);

        }


        public boolean hasRemaining(char[] c)
        {
            for (int i = 0; i < c.length; i++)
            {
                if (c[i] != '-1')
                    return true;
            }

            return false;
        }

  }

1 Answers1

1

Both '10' and '-1' are invalid character constants. That causes the compilation issue.