0% found this document useful (0 votes)
11 views1 page

List 1

The document contains a Java program that extracts a substring from a user-provided string based on specified starting and ending position values. It uses BufferedReader for input and handles potential IOExceptions. The output demonstrates the program's functionality by extracting a substring from 'Senthilkumar'.

Uploaded by

mmabishek4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

List 1

The document contains a Java program that extracts a substring from a user-provided string based on specified starting and ending position values. It uses BufferedReader for input and handles potential IOExceptions. The output demonstrates the program's functionality by extracting a substring from 'Senthilkumar'.

Uploaded by

mmabishek4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

// EXTRACTION OF STRING

import java.io.*;
import java.lang.String;
class list1
{
public static void main(String args[])
{
try
{
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
int a,b;
System.out.println("ENTER THE STRING:");
String s1=in.readLine();
System.out.println("ENTER THE STARTING POSITION VALUE:");
a=Integer.parseInt(in.readLine());
System.out.println("ENTER THE ENDING POSITION VALUE:");
b=Integer.parseInt(in.readLine());
String s2=(s1.substring(a,b));
System.out.println("YOUR CHARACTER STRING IS:" +s2);
}
catch(IOException e)
{
System.out.println("ERROR");
System.exit(1);
}
}
}

OUTPUT:

D:\>cd D:\jdk1.8.0_111\bin

D:\jdk1.8.0_111\bin>javac list1.java

D:\jdk1.8.0_111\bin>java list1
ENTER THE STRING:
Senthilkumar
ENTER THE STARTING POSITION VALUE:
4
ENTER THE ENDING POSITION VALUE:
9
YOUR CHARACTER STRING IS:hilku

You might also like