我只想知道如何在java中調用方法/函數。你能幫我解決這個問題嗎?在java中調用簡單的方法
所以這裏是我的代碼。
import java.util.Scanner;
public class MyFirstProject {
public static void main(String[] args) {
hello();
}
static void hello(int a, int b) {
Scanner scan = new Scanner(System.in);
int total;
System.out.print("Enter first number: ");
a = scan.nextInt();
System.out.print("Enter second number: ");
b = scan.nextInt();
total = a + b;
System.out.println("The total is: " + total);
}
}
問題是? – Kamo