
Sir why we use st.charAt(0). Is there no subsitute for this. Because i m biginner. Thnx

Java input character
You can use System.in.read() also to input a character.
Here is the code:
**class InputCharacter { public static void main(String[] args) throws Exception { System.out.print("Enter a character: "); int i=System.in.read(); char ch=(char) i; System.out.println("you have enetered: "+ch); } }**

Java input character
You can use System.in.read() also to input a character.
Here is the code:
class InputCharacter
{
public static void main(String[] args) throws Exception
{
System.out.print("Enter a character: ");
int i=System.in.read();
char ch=(char) i;
System.out.println("you have enetered: "+ch);
}
}
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.