Why do I have a syntax error in the definition of the for loop of this Java program?

advertisements

I'm working on the below code to create an ArrayList, shuffle it, and take the first three elements but, for some reason, on the line when I start the for loop I get a syntax error on token ";"

import java.util.ArrayList;

public class cardsShuffle {

    ArrayList<String> cards = new ArrayList<>()

    for (int i = 0; i < 52; i++){
        cards.add(String.valueOf(i+1));
        java.util.Collections.shuffle(cards);
    }
    public static void main(String args[]){

        cardsShuffle s = new cardsShuffle();

        System.out.println(s.cards.get(0));
        System.out.println(s.cards.get(1));
        System.out.println(s.cards.get(2));

}


You are missing the semicolon after the line "ArrayList cards = new ArrayList<>()".Just put a semicolon and your code will be error free :)