Start New Discussion within our Software Development Community

Hi everyone,
I need your help please

What do i need to make my program read
the next character

using console.nextChar();

I've added the following:

import java.util.*;
static Scanner console = new Scanner(;

and then in the main:

char ch;

ch = console.nextChar();

and when i compile i get this error::

cannot find symbol
symbol : method nextChar()
location: class java.util.Scanner
ch = console.nextChar();

can any 1 help me please??


Scanner has no definition of method getChar.

so how can i make a program that reads the 1st character that the user enters:

for example:

if user enters :: A 1 2

ch= console.nextChar();
g = console.nextInt();
h= console.nextInt();

what can i use instead of nextChar()??
Thanks in advance

just read it as String, convert it to an array of chars, or make a new Scanner class in which you define a nextChar() method :)

actually i found the answer

String a=;
char b = (char)a.charAt(0);

thanks guys ;)

mmm.... just in case you need this again, a better way to do it is:

variable =;

I hope it helps...:)

hi buddyyyy.. i m ur new friend n recently join to this site...

u have seen ur problemm.... as u r still unable to get single character bu using scanner class....

you shud write:

char ch;
scanner scan = new scanner(;
ch = charAt(0);

when u write the above statement u will able to read a character in java....

hiiii 'buddyyyy ...
if a thread is solved, it means he did succees in getting the caracter.
don't revive threads that haven't been active for over two years, don't revive threads that are marked 'solved' and try to use some proper language.
English is chosen here, since most developers are familiar with it, but then try to keep it with correct grammar and vocabulary, since we don't all have english as our first language.

English is chosen here, since most developers are familiar with it,

The company I work for has 6k developers in America/Europe and 12k developers in India. I would agree that most developers certainly are familiar with English, but from my experience it is broken, heavily-accented English...haha

This question has already been answered. Start a new discussion instead.