+ 1

what is an array ? describe with example.

19th Sep 2016, 5:11 PM
Sadab Khan
Sadab Khan - avatar
6 Antworten
+ 1
An array is just a single variable that stores different information that is neat and organised. This PHP array is much similar to Java, as well as most other arrays in other languages: $food = array("Orange", "Carrot", "Pizza"); // This defines the array "$food" and adds the foods echo $food [1]; // This will echo "Carrot" $food[] = "Apples"; // This will append "Apples" to the array "$food" You can also go: $foods_colors = array("Orange" => "Orange", "Carrot" => "Orange", "Apple" => "Red") This is in PHP though, this is Java: string food = {"Apples", "Carrots", "Pizza"} System.out.println(food[1]); // This will print "Carrots"
23rd Sep 2016, 4:01 PM
William Bohannon
William Bohannon - avatar
0
an array collection all variable in the same time
19th Sep 2016, 8:00 PM
Mohammad Wahab Khan
Mohammad Wahab Khan - avatar
0
Hi Sadab, Array is a collection of same type variables referred by the same name. Each element of array can be accessed via index. In Java, array index always integer starting from 0. Example and more detail of array available in http://javabasictoadvanced.blogspot.co.id/2016/05/array.html
20th Sep 2016, 12:14 PM
Aula Muttaqin
Aula Muttaqin - avatar
0
An array is like having a basket which contains all the different kinds of fruits. You get to add what you want.
28th Sep 2016, 1:12 AM
Boamah Kojo Opoku
Boamah Kojo Opoku - avatar
0
array is container which contain similar data type variables. ex. int array[5] array contain 5 integer value.. i.e. 5,6,7,8,1
29th Sep 2016, 4:17 AM
balram sao
balram sao - avatar
0
The simplest form of example without any programming knowledge goes like this... if your surname is bill and your parents have 5 kids. Without mentioning your first name and last name together, I can aswell call you by your surnames with an assigned number. bill0 , bill1, bill2, bill3, bill4.
21st Oct 2016, 6:43 AM
Franky BrainBox
Franky BrainBox - avatar