用户无法输入字符串变量的值。
这是程序:
import java.io.*;
public class testing
{
char a;
int b;
double c;
String d;
public void method() throws IOException
{
BufferedReader p=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a variable of type 'char'");
a = (char)p.read();
System.out.println("Enter a variable of type 'string'");
d = p.readLine();
System.out.println("Enter a variable of type 'integer'");
b = Integer.parseInt(p.readLine());
System.out.println("Enter a variable of type 'double'");
c = Double.parseDouble(p.readLine());
System.out.println("Your values are: string-" +d +", integer-" +b +", double-" +c);
}
}
有人能看出问题吗?