Java String Array Length Example

Java String Array Length Example



Topic : Total View : 13
/*
Java String Array Length Example
This Java String Array Length example shows how to find number of elements
contained in an Array.
*/
 
public class JavaStringArrayLengthExample {
public static void main(String args[]){
//create String array
String[] strArray = new String[]{"Java", "String", "Array", "Length"};
/*
* To get length of array, use length property of array.
*/
int length = strArray.length;
System.out.println("String array length is: " + length);
//print elements of an array
for(int i=0; i < length; i++){
System.out.println(strArray[i]);
}
}
}
 
/*
Output of above given Java String length example would be
String array length is: 4
Java
String
Array
Length
*/

Post By: Computer Program on Apr 08, 2019 03:13:44 Monday IST
0
0
 




Note : If You want to create Your own New Topic, You can create here any topic for discuss with free mind. Share Your problems without obstacles for make Your mind light.