In my Java class we are currently learning about Dynamic Arrays, but the problem is that the lesson does not teach you how to use them, or the syntax, or anything like that. It tells you what you MIGHT use it for, then it throws you into an example program that is (in my opinion) way too complex for where the class is at right now.
So, what exactly is a Dynamic Array and how do I use it?
Everytime I Google it, it returns something about ArrayList, which is not was I need.
Post a Reply
Replies- page 2
|Oldest Newest Rating|
· February 28, 2015
ArrayList is actually what you need! ArrayList is one of implementation of generic List interface.
List is a collection that takes multiple objects (instances) of same type (it can contain duplicates). It cannot contain objects of different type. I.e.
To add new object call "add" method:
To iterate over list you may use "for each" loop:
or "forEach" method (only Java 8):
You may convert it to "stream" to filter results i.e.:
Returns list where students age is greater then 18.
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|