5th sem OOPJ Write a program to find length of string and print second half of the string.
import java.text.*;
import java.util.*;
/**
*
* @author Yash
*/
class pra4{
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
System.out.println("Enter your String :");
String str = sc.nextLine();
System.out.println("The Length of string is : "+str.length());
System.out.println("Second half of string is :"+str.substring(str.length()/2,str.length()));
}
}
import java.util.*;
/**
*
* @author Yash
*/
class pra4{
public static void main(String arg[]){
Scanner sc = new Scanner(System.in);
DecimalFormat numfor = new DecimalFormat("#.000");//This is to fix after the decimal size.
System.out.println("Enter your String :");
String str = sc.nextLine();
System.out.println("The Length of string is : "+str.length());
System.out.println("Second half of string is :"+str.substring(str.length()/2,str.length()));
}
}
Comments
Post a Comment