Program to extract a portion of a character string and print the extracted string

/* Program to extract a portion of a character string and print the extracted string */

import java.io.DataInputStream;     // to load DataInputStream class        

class P21
{
    public static void main(String args[ ])
    {
        String str1 = new String();
        String str2 = new String();
        int m=0,n=0;
        DataInputStream in = new DataInputStream(System.in);

        try
        {
            System.out.print("Enter String : ");
            str1 = in.readLine();
            System.out.println(" String is : "+str1);
            System.out.print("Enter no. of chracters to be extracted from string : ");
            m = Integer.parseInt(in.readLine());
            System.out.print("Enter starting index : ");
            n = Integer.parseInt(in.readLine());
        }
        catch(Exception e) {  System.out.println("I/O Error");   }

       
        str2=str1.substring(n,(m+n));
        System.out.println(" Extracted String is : "+str2);
    }
}

   
       

3 comments:

tesmoop said...

discover this Continue Find Out More More hints Discover More Here reference

thaysho said...

his comment is here have a peek at this web-site you could try here luxury replica bags check over here this contact form

Anonymous said...

goyard handbags
supreme outlet
golden goose sneaker
hermes outlet online
travis scott jordan
bape hoodie
goyard
air jordan
hermes outlet
jordan shoes

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|