一道程序出现的一个小问题
今天我遇到了一个程序编译时的问题源代码:
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 错误
请问是什么原因呢?小弟刚学不久,希望大家知道的指点下谢谢