This site requires JavaScript, please enable it in your browser!
Greenfoot back
Loled85
Loled85 wrote ...

2015/12/30

List

Loled85 Loled85

2015/12/30

#
How can I make Greenfoot count the number of items within a list? And how do I set a maximum size for that list?
danpost danpost

2015/12/30

#
Loled85 wrote...
How can I make Greenfoot count the number of items within a list? And how do I set a maximum size for that list?
You do not need 'Greenfoot' for counting the number of items within a list. If you refer to the List class API documentation, you will find it has a 'size' method. You cannot set a maximum size of a List object (you can, however, create an ArrayList object with an initial capacity; but that does not limit the capacity); but, you can use its size as a condition to add items to the list.
Loled85 Loled85

2015/12/30

#
Oh right, I totally forgot about that last part with the condition. Thank you!
You need to login to post a reply.