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
Define a class to accept values into an integer array of order 4 x 4 and check whether it is a DIAGONAL array or not. An array is DIAGONAL if the sum of the left diagonal elements equals the sum of the right diagonal elements. Print the appropriate message.
Example:
3 4 2 5
2 5 2 3
5 3 2 7
1 3 7 1Sum of the left diagonal element = 3 + 5 + 2 + 1 = 11
Sum of the right diagonal element = 5 + 2 + 3 + 1 = 11
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.
Consider the following two-dimensional array and answer the questions given below:
int x[ ][ ] = {{4,3,2}, {7,8,2}, {8, 3,10}, {1, 2, 9}};(a) What is the order of the array?
(b) What is the value of x[0][0]+x[2][2]?