-
Notifications
You must be signed in to change notification settings - Fork 1
Arrays in Java
-
They are a fixed length, which will never change
-
You have to make the array the correct size in the first place. Arrays are like a set of cabinets in a kitchen to fill up. You specify how long the array is by putting in a number within the square brackets of a new array String[] names = new String[3]; names[0] = "Sharina"; // to fill up the array
-
You must specify the type of data that goes in that array. Int array, String array. There is mostly no mixed arrays.
-
Another more common way to create an array: String array names equals new string array using curly braces. Within the curly braces we put the data we want to live within the array. Using this way lets Java determine how long the array is on its own.
String[] names = new String[]{"Michelle", "Nicholas", "Jeff"};
- Arrays hold things in order
- Hold only a fixed number things