Dividend = Integer. parseInt (args [0]) parameter problem, integer. parseint Parameter

Source: Internet
Author: User

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 ".

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.