I am missing something here? NetBeans is saying that it’s expecting a “(” or “[” [closed] Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of I am missing something here? NetBeans is saying that it’s expecting a “(” or “[” [closed] without wasting too much if your time.

The question is published on by Tutorial Guruji team.

public void getComputerPlayerTurn(String pid, ScopaCard card) {
    //checkPlayerTurn(pid);
    getPlayerHand(pid);
    int tempInt = playerHand.size();
    ArrayList<Rank> tempRanks = new ArrayList<Rank>           
        
    for (int i = 0; i < tempInt; i++) {
        card = playerHand.get(i).get(i);
        tempRanks.add(card.getRank());
    }
}

That’s my code for a method that I’m trying to create. The aim of this for loop is to get the cards in a players hand, and add their ranks to a different ArrayList. Everything is fine apart from the top line of the for loop (the one that has for (int i = 0; ...)). Here it is saying that a ( or [ is expected. I have no idea where though. Cheers.

Answer

ArrayList<Rank> tempRanks = new ArrayList<Rank>

You forgot to put the constructor’s brackets on the ArrayList. It should look like this:

List tempRanks = new ArrayList<>();
We are here to answer your question about I am missing something here? NetBeans is saying that it’s expecting a “(” or “[” [closed] - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji