标题:一道程序出现的一个小问题
取消只看楼主
zjmantou
Rank: 1
等 级:新手上路
帖 子:11
专家分:5
注 册:2010-11-27
结帖率:100%
 问题点数:0 回复次数:0 
一道程序出现的一个小问题
今天我遇到了一个程序编译时的问题
源代码:
public class ch5ex4{
    static void swap(int x, int y){
        System.out.print("Before swap:");
        System.out.println("x = " + x + "y = " +y);
        int temp=x ; x=y ; y=temp;
        System.out.print("After swap:");
        System.out.println("x = " + x + "y =" + y);
    }
    public static void main(String[]args){
        int num1,num2;
        System.out.print("Enter a num1:");
        num1 = Keyboard.readInt();
        System.out.print("Enter a num2:");
        num2 = Keyboard.readInt();
        System.out.print("Before calling:");
        System.out.println("num1 = " + num1 + "num2 =" + num2);
        swap(num1,num2);
        System.out.print("after calling:");
        System.out.println("num1 = " + num1 + "num2 =" + num2);
    }
}
编译时提示
E:\testjava>javac ch5ex4.java
ch5ex4.java:12: 找不到符号
符号: 变量 Keyboard
位置: 类 ch5ex4
                num1 = Keyboard.readInt();
                       ^
ch5ex4.java:14: 找不到符号
符号: 变量 Keyboard
位置: 类 ch5ex4
                num2 = Keyboard.readInt();
                       ^
2 错误
请问是什么原因呢?小弟刚学不久,希望大家知道的指点下谢谢
搜索更多相关主题的帖子: 源代码 
2011-04-18 15:26



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-337095-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.845868 second(s), 10 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved