Answers for "add string to array"

5

how to push string into array in javascript

var arr = ["Hi","Hello","Bonjour"];
arr.push("Hola");
console.log(arr);
Posted by: Guest on January-18-2021
3

how to push array

//the array comes here
var numbers = [1, 2, 3, 4];

//here you add another number
numbers.push(5);

//or if you want to do it with words
var words = ["one", "two", "three", "four"];

//then you add a word
words.push("five")

//thanks for reading
Posted by: Guest on June-27-2020
0

add string to array java

in java, once you declared an array you cannot change its size.
so that adding an element to the array is not possible.
you can declare an arraylist, which is the same as array but its resizable.
meaning that you can add or remove at any time and as much you want.
for example:
ArrayList<String> languages = new ArrayList<String>(); 
languages.add("PHP");
languages.add("JAVA");
languages.add("C#");
ArrayList<int> numbers = new ArrayList<int>(); 
numbers.add(9);
numbers.add(14);
numbers.add(2);
Posted by: Guest on June-17-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language