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

Long Answer
Views 79

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

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.