Tuesday 21 July 2015

Write a program to find length of string and print second half of the string.

  
         
import java.util.Scanner;

public class Program_4 {
    
    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        
        System.out.println("Lenght of String : "+str.length());
        System.out.println("Print second half : "+str.substring(str.length()/2));     
    }  
} 
        
  

No comments:

Post a Comment