Find Length of String
This program finds the length of a string.
Problem Statement
Write a Java program to find the length of a given string.
Source Code
| 1 | public class StringLength { |
| 2 | public static void main(String[] args) { |
| 3 | System.out.println("Eduinq String Length"); |
| 4 | String str = "Eduinq"; |
| 5 | System.out.println("Length of string: "+str.length()); |
| 6 | } |
| 7 | } |
Program Output
Eduinq String Length Length of string: 6
Explanation
The string str is initialized with "Eduinq", and the length() method returns the number of characters it contains, demonstrating basic string length calculation.