Java exception exit condition judgment example code

Whether functional code or algorithmic code, the program is a collection of a series of processes

Since it is a process, it is divided into: general process and abnormal process;

The general process ensures the basic functions;

The abnormal process is the guarantee of program stability, and the project cannot hang up because of some illegal input;

Note that the order of Boolean expressions is sometimes not interchangeable

0. Common abnormal exit conditions

The parameter is null;

Indicates the length, indicates that the integer of the index is negative, or exceeds the range of the array or container to be indexed;

1. Startswith function of string

First, let's look at the external interface provided by the string class for the startswith function. There are two function overloads in the following forms:

The meanings of the parameters passed in are: prefix: the string to be matched, toffset the offset at the beginning of the comparison of the current string. For the parameters, the following conditions should be met:

toffset >= 0; this. value. length >= prefix. length + toffset

That is:

The complete source code is as follows:

summary

The above is the whole content of this article's sample code for judging Java exception exit conditions. It will be helpful to you after washing. Interested friends can continue to refer to this site: Java programming exception handling best practice [recommended], check type exception and non check type exception analysis in Java programming, etc. if you have any questions, you can leave a message at any time. Xiaobian will reply to you in time.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>