Home / Questions / Write statements to show how finding the length of a character array char[] differs from finding the length of a String object str.
Explanatory Question

Write statements to show how finding the length of a character array char[] differs from finding the length of a String object str.

👁 84 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

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();