Hi guys I need the equivalent java code of this PHP code:
<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
?>
the Output is:
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspberry
)
You have to use a ArrayList
.
List<String> list = new ArrayList<String>();
list.add("orange");
list.add("banana");