Java Scanner获取char

时间:2015-12-23 12:32:27

标签: java java.util.scanner

import java.util.Scanner;

public class myClass {
    public static void main(String[] args)
    {
        String[] exampleString;
        char expression;
        Scanner getExp = new Scanner(System.in);
        while(expression = getExp.next().charAt(0))
        {
           // myString will added by expression character
        }

    }
}

我在Eclipse Mars上试过但是

expression = getExp.next().charAt(0) part gets error always.

我不明白错误是什么。

以前我想在这个链接上 stackoverflow Scanner question

我认为错了?

1 个答案:

答案 0 :(得分:2)

你可能想要

tempReportPath