这个java程序有什么问题。?

[复制链接]
查看11 | 回复5 | 2011-4-2 03:50:32 | 显示全部楼层 |阅读模式
public class hgf {

/**
* @param args
*/
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);
}
}
回复

使用道具 举报

千问 | 2011-4-2 03:50:32 | 显示全部楼层
<pre id=\"best-answer-content\" class=\"reply-text mb10\">Keyboard 类未定义。。。。
回复

使用道具 举报

千问 | 2011-4-2 03:50:32 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-3306041\">什么头文件。本人初学者。
回复

使用道具 举报

千问 | 2011-4-2 03:50:32 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-3321342\">这个不清楚,你要学会自己查资料的,我现在没学JAVA
回复

使用道具 举报

千问 | 2011-4-2 03:50:32 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-3306291\">怎么定义啊。谢谢。本人初学者
回复

使用道具 举报

千问 | 2011-4-2 03:50:32 | 显示全部楼层
<pre class=\"replyask-text\" id=\"content-3307246\">在java里面类在使用之前必须定义
下面仅供参考
public class Keyboard
{
public static char readChar()
{}
public static voidskipLine()
{}
}
这只是一个包含两个方法的空类(没有任何逻辑)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行