Javascript – Arrays

Javascript – Arrays

An array is a container with an index that you can store in many values. You can declare an array: var persons = []; The above is an empty array. You can also declare an array with its values var persons = [“Kronos”, “Zeus”, “Ira”]; You can access an array element using indexes, starting from 0 console.log(persons[1]); //will print Zeus You can change the value of an array using indexes: persons[2] = “Afroditi”; Arrays are objects. That means they have methods and properties which you can access using the “.”…

Javascript – Arrays Read More

Java – Arrays

Java – Arrays

Array is an object that you can store data of the same type. In other words, it is a collection of variables with zero-based indexing. You cannot change the size of the array. When an array is initialized all element will be: 0 for int 0.0 for double false for boolean null for objects syntax / initialization: type[] arrayName = new type[length]; example: int[] numbers = new int[10]; Array element is one value, index is the position of an array element in the array, base type is the kind of…

Java – Arrays Read More