整数除法,无异常处理。
import java.util.Scanner; public class Main { /** from n o w j a v a . c o m - 时 代 Java**/ // demonstrates throwing an exception when a divide-by-zero occurs public static int quotient(int numerator, int denominator) { return numerator / denominator; // possible division by zero } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); /*N o w J a v a . c o m 提供*/ System.out.print("Please enter an integer numerator: "); int numerator = scanner.nextInt(); int denominator = 0;