
What is array and how can i add an element into an array in Java? IT would be nice if you can give an example.
Thanks!

hi friend,
Array is a group of similar type of elements. This is a very important concept of a programming languages that implements the Array variable. It contains the list of elements of similar types.
In Java, size of array is fixed when it is created so we can't add additional value into it. For the variable size of array you would be required to implement the List as ArrayList of java.util.Collection
A simple example of adding element into an array is given as below hope this will helpful for you.
public class AddElement
{
public static void main(String args[])
{
int num = 0;
int lastNum = 10;
int[] numArray = new int[lastNum];
for(int i = 0; i < numArray.length; i++)
{
numArray[i] = num;
num++;
System.out.print(numArray[i] + " ");
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.