Review java - Array
113 words
One minute
Declaring an array
Both are allow
1
2
| string argc[];
string[] argc;
|
Int array
1
2
| int[] nums = new int[7];
nums[0] = 10;
|
1
2
| Rabbit[] racers = new Rabbit[10];//10 empty rabbit array;
racers[0] = new Rabbit("B","F");
|
arraycopy()
1
| System.arraycopy(nums, 0, nums, 0, nums.length);
|
Array vs ArrayList
- An array needs to know its size at the time of creation, arrayList does not.
- To assign an object in array you must assign it to a specific index.
- Array use array syntax ([]).
- ArrayList is parameterized.
ArrayList<string>
ArrayList
1
2
3
4
5
6
| ArrayList<Flower> flowerList = new ArrayList<Flower>();// <- ArrayList constructor
Flower f = new Flower();
Flower m = new Flower();
flowerList.add(f);
flowerList.add(m);
|