请问一下高手 
char类型的要用什么方法来接收用户输入
比如:Scanner input = new Scanner(System.in);
System.out.println("请输入运算符<+ - * />");
char yunsuan = input.XXXXXX();XXXX用什么方法
int 类型是nextInt();
那char 用什么类型望高手赐教

解决方案 »

  1.   

    char yunsuan = input.nextByte() ;
      

  2.   

    晚了一步结贴太快
    转化成真正的char还是很麻烦的.
    楼上转的是string和char还是不一样的char是无符号16位
    class C {
    public static char byteToChar(byte[] b) {
    int s = 0;
    if (b[0] > 0)
    s += b[0];
    else
    s += 256 + b[0];
    s *= 256;
    if (b[1] > 0)
    s += b[1];
    else
    s += 256 + b[1];
    char ch = (char) s;
    return ch;
    } public static void main(String[] args) {
    System.out.println("请输入运算符 <+ - * />");
    Scanner input = new Scanner(System.in);
    System.out.println(input.nextLine());
    char a = byteToChar(input.nextLine().getBytes());
    System.out.println(a);
    }
    }