Showing posts with label Length of String. Show all posts
Showing posts with label Length of String. Show all posts

Saturday, 26 July 2014

How to find length of a string in Java

Structure of the Problem Requirements 


In this simple problem we learn how to find out the length of a string in Java. Java language provide 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());
       
    }
    
}


Output of the Program


Java String Programming
Java String Pogramming