Computer Applications
Write statements to show how finding the length of a character array char[] differs from finding the length of a String object str.
Java Arrays
ICSE 2013
10 Likes
Answer
Java code snippet to find length of character array:
char ch[] = {'x', 'y', 'z'};
int len = ch.length
Java code snippet to find length of String object str:
String str = "Test";
int len = str.length();
Answered By
6 Likes
Related Questions
Write a Java program to store n numbers in an one dimensional array. Pass this array to a function number(int a[]). Display only those numbers whose sum of digit is prime.
The statement used to find the total number of Strings present in the string array String s[] is:
- s.length
- s.length()
- length(s)
- len(s)