Home > Java > JavaBase > Introduction to the method of determining whether it is a triangle in java

Introduction to the method of determining whether it is a triangle in java

Release: 2019-11-22 09:49:32
Original
5475 people have browsed it

Introduction to the method of determining whether it is a triangle in java

Write a method void triangle(int a, int b, int c) to determine whether the three parameters can form a triangle. If it cannot be formed, an exception IllegalArgumentException will be thrown and the exception information will be displayed: a, b, c "Cannot form a triangle"; if it can be formed, the three side lengths of the triangle will be displayed. In the main method, get the three integers input from the command line, call this method, and catch the exception.

a

The sum of the two sides is greater than the third side: a b>c

The difference between the two sides is less than the third side: c-a

Run results:

Introduction to the method of determining whether it is a triangle in java

For more java knowledge, please pay attention to java basic tutorial.

The above is the detailed content of Introduction to the method of determining whether it is a triangle in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template