Dividend = Integer. parseInt (args [0]) parameter problem, integer. parseint Parameter
Let's start with a piece of code:
1 package yichang; 2 3 public class MyExceptionTest {4 5 public static void main (String [] args) {6 int dividend = 0; 7 int divisor; 8 int result = 0; 9 try {10 dividend = Integer. parseInt (args [0]); 11 divisor = Integer. parseInt (args [1]); 12 result = dividend/divisor; 13 System. out. println ("redult =" + result); 14} catch (ArrayIndexOutOfBoundsException e) {15 System. out. println ("too few input parameters, please enter two parameters"); 16 17} catch (NumberFormatException e) {18 System. out. println ("the parameter format is incorrect. Please enter two numbers"); 19} catch (ArithmeticException e) {20 System. out. println ("Division: 0"); 21} 22 23} 24 25}
Beginner
Dividend = Integer. parseInt (args [0]); divisor = Integer. parseInt (args [1]);
There will be some confusion, so we need to select the project -- run mode -- run Configuration
Set the program independent variables and click "Application -- run ".