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

How to jump out of if in java

angryTom
angryTomOriginal
2019-11-14 13:56:358699browse

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
   // 以下有多行代码
  }
}

2. Use break to jump out of multiple if

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

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!

Statement:
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