Program demonstrating use of string methods.
The program demonstrates accepting string from the user and calculating
the length using the string class method length().
/********************************************** * Calculating string length in Java * * code.cheraus.com ***********************************************/ import java.util.Scanner; class String_Length { public static void main(String args[]) { Scanner str = new Scanner(System.in); System.out.print("Enter the string : "); String s = str.nextLine(); int len = s.length(); System.out.println("The length of " + len); } }