Answer:
//import package
import java.util.*;
// class name
class Solution
{
// method to remove the character at given index
public static void deleteLetter(String st,int in)
{
// remove the character at index in
st=st.substring(0,in-1)+st.substring(in);
System.out.println(st);
}
// main method of class
public static void main (String[] args) throws java.lang.Exception
{
try{
//scanner object to read input
Scanner scr=new Scanner(System.in);
// read string
System.out.print("Enter the string:");
String st=scr.nextLine();
// read index
System.out.print("Enter the index:");
int in=scr.nextInt();
// call method
deleteLetter(st,in);
}catch(Exception ex){
return;}
}
}
Explanation:
Read a string with the help of Scanner object.Then read the index of character to be remove.Call the method deleteLetter() with parameter string and index.It will make substring from 0 to "in-1" and "in" to last of the string.Then add both the string.This will be the required string.
Output:
Enter the string:timetable
Enter the index:3
tietable