public class CollectionTest {
public static void main(String args[]) {
//create Scanner instance to get input from User
Scanner scanner = new Scanner(System.in);
System.err.println("Please enter first number to add : ");
int number = scanner.nextInt();
System.out.println("Enter second number to add :");
int num = scanner.nextInt();
//adding two numbers in Java by calling method
int result = add(number, num);
System.out.printf(" Addition of numbers %d and %d is %d %n", number, num, result);
}
public static int add(int number, int num){
return number + num;
}
}
我想知道这段代码有什么问题。当我在我的新笔记本电脑上运行这个程序时,它工作正常。但是在我的旧电脑上它给出了一些错误。请帮帮我。Thnx提前.d