Reputation: 31
When I calling the size
method of my ArrayList
, I get the error:
size has private access in ArrayList.
Any advice on this?
ArrayList<String> sAnswers = new ArrayList<>();
int arrayL = sAnswers.size;
Upvotes: 0
Views: 1617
Reputation: 2417
There is no accessible size
variable in List
. It's a method
Access it like sAnswers.size();
Upvotes: 4
Reputation: 102
size
is a private
variable in List
. Use someList.size()
.
length
is a public
variable in an Array
. Use someArray.length
.
ArrayList<String> sAnswers = new ArrayList<>();
int arrayL = sAnswers.size();
Upvotes: 2