Showing posts with label delete free space in starting of string. Show all posts
Showing posts with label delete free space in starting of string. Show all posts

Saturday, 15 June 2013

Use of java string function - trim()

import java.io.*;

public class trim
{
    public static void main(String []args)
    {
        String str,str_2;
        try
        {
            DataInputStream cin=new DataInputStream(System.in);
            System.out.println("Enter any String ");
            str=cin.readLine();
            System.out.println("Your entered string is = "+str);
            str_2=str.trim();
            System.out.println(str_2);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}