scanner « character « Java Data Type Q&A

1. Scanner method to get a char

What is the Scanner method to get a char returned by the keyboard in Java. like nextLine() for String, nextInt() for int, etc.

2. Scanner cuts off my String after about 2400 characters

I've got some very basic code like

while (scan.hasNextLine())
    String temp = scan.nextLine();
where scan is a Scanner over a file. However, on one particular line, which ...

3. Char using Scanner

I'm new to Java. I want to be able to input operational characters in a Scanner. My code should produce the following,

  1. Enter two numbers: 13 6
  2. What operation? *
  3. What is 13 ...

4. using switch, scanner and char

if (grade == 4.0) letterGrade = 'A'; else if (grade == 3.0) letterGrade = 'B'; else if (grade == 2.0) letterGrade = 'C'; else if (grade == 1.0) letterGrade = 'D'; else if (grade == 0) letterGrade = 'F'; System.out.println("Enter your Maths letter grade: "); letterGrade =; System.out.println("Enter your Physics letter grade: "); letterGrade =; System.out.println("Enter your Chemistry letter ...

5. Scanner, syntax, char, string help, etc.

6. How to use the scanner class to ask for a character?

I know you're trying to help, but this isn't really doing it. It does nothing to address the source of the OP's problem. The way he's doing it now is almost right. He just needs to do a tiny bit of detective work to fix a small bug. Tossing off a totally different approach, with no explanation, is not particularly helpful. ...

7. Char and scanner

8. Troubles using scanner to match blank lines or lines that start with a char

By default, the regular expressions ^ and $ ignore line terminators and only match at the beginning and the end, respectively, of the entire input sequence. If MULTILINE mode is activated then ^ matches at the beginning of input and after any line terminator except at the end of input. When in MULTILINE mode $ matches just before a line terminator ...