OneBite.Dev - Coding blog in a bite size

create an array of number in java

Code snippet on how to create an array of number in java

int[] numbers = {1,2,3,4,5};

This code creates an array of numbers in Java. An array is a collection of elements that are accessed by index number. In this example, an int array is created with 5 elements (1,2,3,4,5). This is done by declaring a variable called “numbers” of type int array and assigning the elements to it in curly braces {}. The elements in this array can then be accessed by index numbers such as numbers[0] (returns 1) or numbers[4] (returns 5). An array can be used to store multiple values of similar type in an organized way.

java