
Q1: Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The integer argument is a character position within the String, with the first character being at position 0. When the method executes, it should display the character at that character position. Here is an example of a call the method:
showChar("New York", 2);
In this call, the method will display the character w because it is in position 2. Demonstrate the method in a complete program.

class StringExample9
{
public void showChar(String st,int index){
char ch=st.charAt(index);
System.out.println(ch);
}
public static void main(String[] args)
{
StringExample9 ex=new StringExample9();
String str="Hello World";
int i=8;
ex.showChar(str,i);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.