Home > Java > JavaBase > How to jump out of if in java

How to jump out of if in java

angryTom
Release: 2019-11-14 13:56:35
Original
8764 people have browsed it

How to jump out of if in java

How to jump out of if in java

We often use if statements when writing code. When if() is judged as When it is true, the statement after the if will be executed. When it is judged to be false, it will not be executed.

If we want to jump out of multiple if statements, how should we do it? Here is a method to jump out of multiple if statements. (Recommended tutorial: java tutorial)

1. Normal logical judgment is written like this

if(...){
    // do something
   // 如果为true进入
  if(condition==true){       
    // do something
   // 以下有多行代码
  }
}
Copy after login

2. Use break to jump out of multiple if

标签1: if(...) {
    // do something
   if(condition==false)
         break 标签1;          
     // do something
     // 以下有多行代码
}
Copy after login

The above is the detailed content of How to jump out of if in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template