kamikaze_pilot kamikaze_pilot - 1 year ago 100
Java Question

How can I dynamically add items to a Java array?

In PHP, you can dynamically add elements to arrays by the following:

$x = new Array();
$x[] = 1;
$x[] = 2;

After this,
would be an array like this:

Is there a way to do something similar in Java?

Answer Source

Look at java.util.LinkedList or java.util.ArrayList

List<Integer> x = new ArrayList<Integer>();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download