Manu

Showing posts with label WAP to find length of string and print second half of the string. Show all posts
Showing posts with label WAP to find length of string and print second half of the string. Show all posts

Saturday, November 19, 2016

WAP to find length of string and print second half of the string


CODE:
import java.util.*;
class SubString
{
     public static void main(String m[])
    {
         Scanner in=new Scanner(System.in);
         String s=new String();
         System.out.println("Enter a String :");
         s=in.next();
         int l=s.length();
         System.out.println("Length of the string "+s+" is "+l);
         System.out.println("Your sub String is:"+s.substring(l/2));
     }
}

OUTPUT: