Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Java logical operator

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge points of Java logic operator instance analysis, the content is detailed, the logic is clear, I believe most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

1. Preface logic operators are all Boolean operands left and right, and the result of the expression is also Boolean type true or false II. Logic operator & logic and as long as one Operand is false, then the result must be false & & short circuit and high efficiency. As long as the left is false, the right will not be calculated, and the result must be false | Logic or as long as one Operand is true. Then the result must be true | | short circuit or high efficiency, as long as the left is true, then the right is not calculated, the result must be true! Logic is not the result on the contrary ^ logic XOR left and right operands are different the result is true, the same result is false 3, code public class LearnOpra03 {public static void main (String [] args) {/ / & logic and as long as one Operand is false, then the result must be false System.out.println ("1 Operand =") System.out.println (true&true); System.out.println (true&false); System.out.println (false&true); System.out.println (false&false) / / & short circuit and high efficiency. As long as the left side is false, then the right side is not calculated. The result must be false System.out.println ("2 cycles ="); System.out.println (true&&true); System.out.println (true&&false); System.out.println (false&&true). System.out.println (false&&false); / / | logical or as long as one Operand is true, the result must be true System.out.println ("3 operations ="); System.out.println (true | true); System.out.println (true | false); System.out.println (false | true) System.out.println (false | false); / / | short circuit or high efficiency, as long as the left side is true, then the right side is not calculated, and the result must be true System.out.println ("4 cycles ="); System.out.println (true | | true); System.out.println (true | | false) System.out.println (false | | true); System.out.println (false | | false); / /! Logic is not the result of the reverse System.out.println ("5 minutes ="); System.out.println (! true); System.out.println (! false) / / logical XOR left and right operands are different the result is true, the same result is false System.out.println ("6 percent ="), System.out.println (true ^ true), System.out.println (true ^ false), System.out.println (false ^ true) System.out.println (false ^ false);}} IV. Practice public class LearnOpra04 {public static void main (String [] args) {int iFix1; System.out.println ("1 false ="); System.out.println ((1 > 2) & & (iSuppli false 2)); / / false System.out.println (I) / / 1 iTunes 1; System.out.println ("2 cycles ="); System.out.println ((1 > 2) & (iatrogenic cycles 2)); / / false System.out.println (I); / 2 iatro1; System.out.println ("3 cycles =") System.out.println ((1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report