Programming project. blackjack, String array issue

AI Thread Summary
The issue in the Blackjack class arises from a missing comma between "Spades" and "Clubs" in the String array declaration for arraySuit. This omission leads to compilation errors when the code is executed. Correcting the array declaration by adding the comma resolves the errors. The discussion highlights the importance of syntax accuracy in Java programming. Properly formatting arrays is crucial for successful code compilation and execution.
opaquin
Messages
10
Reaction score
0
Not sure what's going one, as soon as I remove the line with String[] arraySuit... all errors go away. With that statement in I get errors on several lines. Cannot figure out what's wrong.

Code:
/*
 * Semester Project
 * Blackjack Class
 */
package project;
import java.util.*;

/**
 * Oliver Paquin
 * CIS132
 * December 10, 2012
 */

class Blackjack 
{
    //declare and set arrays for suits and cards
    String[] arraySuit = {"Hearts", "Diamonds", "Spades" "Clubs"};
    int[] arrayCards = {1,2,3,4,5,6,7,8,9,10,11,12,13};
    
    
    int number1, number2;
    
    public int dealCards()
    {
        //Create Random class object
        Random randomNumbers = new Random();
        
        number1 = randomNumbers.nextInt(3);
        number2 = randomNumbers.nextInt(12);  
        
                 
        //Display random numbers for testing
        
        System.out.println(arrayCards[number2]);
        
        return number1;
        
    }
    
}
 
Physics news on Phys.org
Could it be because you're missing a comma between "Spades" and "Clubs"?

(Since "Spades" and "Clubs" are separate strings in the array, they need to be separated by a comma.)
 
Thanks...tomorrow I'm going to get my eyes checked.
 

Similar threads

Replies
2
Views
1K
Replies
12
Views
2K
Replies
3
Views
2K
Replies
6
Views
3K
Replies
3
Views
3K
Replies
12
Views
4K
Back
Top