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






Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment