Java programming provides builtin function to find the length of any string. Remember when we use string function to find its length then spaces are included in it.
Source Code
package com.ancodingpoint.ww; import java.util.Scanner; public class String_Length { public static void main(String[] args) { Scanner input = new Scanner (System.in); String sentence = ""; System.out.println(" Enter Your Story ..."); sentence = input.nextLine(); System.out.print(" The Total Characters included spaces in your story are :"); System.out.println(sentence.length()); } }
0 comments:
Post a Comment