A string array is an array where we can store only string values in the array, with the help of a string array, we can store more than one string value. We can declare the string array in many ways like declaring a static string array, declaring a variant size array of string using the Array function, and a string array using the split function which we will discuss in this article
Declaring a Static String Array
A static Array is an array whose size is fixed and it can be declared in two ways one is declared implicitly and another one is explicit.
The following code is to declare a string array implicitly.
The following code is to declare a string array explicitly.
Declaring a Variant Size Array of String using Array Function
In the following code an array is declared with variant size and string values are initialized using the array function:
If we want to access the strings in the array then we have to write,
Declaring a String Array using Split Function
The following code is to declare an array without any fixed size and a split function is used to assign the string values.
If we want to access the strings in the array then we have to write,
By default, the lower bound of an array is 0, and the upper bound of an array is n.
Where,
lower bound is the lowest index of the array,
upper bound is the highest index of the array.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now !
Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!
Last Updated :
11 Nov, 2022
Like Article
Save Article
Share your thoughts in the comments
Add Your Comment
Please Login to comment...