这个java程序有什么问题

publicclasshehe{publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubchar... public class hehe {

public static void main(String[] args) {
// TODO Auto-generated method stub
char ch1,ch2,ch3;
System.out.print("Enter first character:");
ch1=Keyboard.readChar(); //移去缓冲区的回车符
Keyboard.skipLine(); //这行有问题
System.out.println();
System.out.print("Enter second character:");
ch2=Keyboard.readChar(); //这行有问题
System.out.println();
System.out.print("Enter third charater:");
ch3=Keyboard.readChar(); //这行有问题
System.out.println();
if(ch1<=ch2)
{
char temp;
temp = ch1;
ch1 = ch2;
ch2 = temp;
}
if(ch1<=ch3)
{
char temp;
temp = ch1;
ch1 = ch2;
ch2 = temp;
}
if(ch2<=ch3)
{
char temp;
temp = ch2;
ch2 = ch1;
ch1 = temp;
}
System.out.print("Sorted:");
System.out.println(ch1);
System.out.println(ch2);
System.out.println(ch3);
}
}
展开
 我来答
YOUREclipse
2011-05-06 · TA获得超过292个赞
知道小有建树答主
回答量:198
采纳率:0%
帮助的人:104万
展开全部
KeyBoard的作用是什么啊!
追问
从键盘输入啊
追答
应该是这样的吧!你就想从键盘输入三个字符吧!
public static void main(String[] args) {
// TODO Auto-generated method stub
char ch1,ch2,ch3;
Scanner Keyboard = new Scanner(System.in);
System.out.print("Enter first character:");
ch1=Keyboard.next().charAt(0); //移去缓冲区的回车符
// Keyboard.skipLine(); //这行有问题
System.out.println();
System.out.print("Enter second character:");
ch2=Keyboard.next().charAt(0); //这行有问题
System.out.println();
System.out.print("Enter third charater:");
ch3=Keyboard.next().charAt(0); //这行有问题
System.out.println();
if(ch1<=ch2)
{
char temp;
temp = ch1;
ch1 = ch2;
ch2 = temp;
}
if(ch1<=ch3)
{
char temp;
temp = ch1;
ch1 = ch2;
ch2 = temp;
}
if(ch2<=ch3)
{
char temp;
temp = ch2;
ch2 = ch1;
ch1 = temp;
}
System.out.print("Sorted:");
System.out.println(ch1);
System.out.println(ch2);
System.out.println(ch3);
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式