Saatana
Saatana

Reputation: 1167

How to accept an arraylist into a method

just a quick question.. how do you accept an arraylist into a method? Right now I have:

public void getHandValue(ArrayList< Card > hand) {...}

Just the word "ArrayList" is coming up as an error. The arraylist is in my main args. I'm very new to java so I'm sorry if this is a dumb question. Thanks in advance!

Upvotes: 1

Views: 1189

Answers (2)

JohnnyK
JohnnyK

Reputation: 1102

A good practice is to use List < Card > in your signature, too. Even if you're passing an ArrayList into the method.

You should try to keep your methods as generic as posssible.

Upvotes: 2

Rob Hruska
Rob Hruska

Reputation: 120286

Have you imported it at the beginning of your class file?

import java.util.ArrayList;

Upvotes: 7

Related Questions