How do you accept a character from user in Java?

We need to use the next() method to read a single character as a string and then use charAt(0) to get the first character of that string . Scanner scanner = new Scanner(System.in); char ch = scanner. next(). charAt(0);

Sizin İçin Seçtik  What is nextLine method in Java?

Leave a Reply

Your email address will not be published. Required fields are marked *