Cannot define ArrayList<char>
as argument of validate
. Why it cannot be done? When trying ArrayList<?>
it works. Why? Should ArrayList<?>
be used instead of ArrayList<char>
? What is the difference?
public boolean validate(ArrayList<char> args){ ... }
Error: Syntax error on token "char", Dimensions expected after this token
You cannot create an ArrayList of primitive types like int , char etc. You need to use boxed types like Integer , Character , Boolean etc. Java ArrayList is not synchronized. If multiple threads try to modify an ArrayList at the same time, then the final outcome will be non-deterministic.
ArrayList cannot hold primitive data types such as int, double, char, and long.
ArrayList accepts only reference types as its element, not primitive datatypes. When trying to do so it produces a compile time error.
If your intent is to just pass an ArrayList to a method that is inside of Hand , do the following: Change the method's name to something else (that doesn't start with a capital), and get rid of the new keyword in the main .
public boolean validate(List<Character> args){ ... }
It has to be the wrapper type - Character
- List<Character>
. You can't use generics with primitive types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With