日期:2014-05-20  浏览次数:20747 次

代码问题,想做个可以多次判断的,但每次判断结束后,总输出两行不想要的东西。
import   java.io.*;
public   class   UpLow
{
public   static   void   main(String[]args)throws   IOException
{
char   x;
do
{
System.out.println( "please   enter   a   letter: ");
x=(char)System.in.read();
if(Character.isUpperCase(x))
System.out.println( "The   letter   you   input   is   upperCase ");
else   if(Character.isLowerCase(x))
System.out.println( "The   letter   you   input   is   lowerCase ");
else
System.out.println( "------------------- ");
}while(x!= '1 ');
}
}

------解决方案--------------------
x=(char)System.in.read();

java里的键盘输入是这么写么?

我怎么记得得用
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
------解决方案--------------------
import java.io.*;

public class d
{
public static void main(String[]args)throws IOException
{
char x;
do
{
System.out.println( "please enter a letter: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//x=(char)br.readLine().toString();
x = br.readLine().charAt(0);
if(Character.isUpperCase(x))
System.out.println( "The letter you input is upperCase ");
else if(Character.isLowerCase(x))
System.out.println( "The letter you input is lowerCase ");
else
System.out.println( "------------------- ");
}while(x!= '1 ');
}
}