CINXE.COM
java - What are the cases in which it is better to use unconditional AND (& instead of &&) - Stack Overflow
<!DOCTYPE html> <html itemscope itemtype="https://schema.org/QAPage" class="html__responsive " lang="en"> <head> <title>java - What are the cases in which it is better to use unconditional AND (& instead of &&) - Stack Overflow</title> <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196"> <link rel="apple-touch-icon" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <link rel="image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml"> <link rel="canonical" href="https://stackoverflow.com/questions/11411907/what-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of" /> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0"> <meta property="og:type" content= "website" /> <meta property="og:url" content="https://stackoverflow.com/questions/11411907/what-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of"/> <meta property="og:site_name" content="Stack Overflow" /> <meta property="og:image" itemprop="image primaryImageOfPage" content="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon@2.png?v=73d79a89bded" /> <meta name="twitter:card" content="summary"/> <meta name="twitter:domain" content="stackoverflow.com"/> <meta name="twitter:title" property="og:title" itemprop="name" content="What are the cases in which it is better to use unconditional AND (& instead of &&)" /> <meta name="twitter:description" property="og:description" itemprop="description" content="I'd like to know some cases in Java (or more generally:
in programming) when it is preferred in boolean expressions to use the unconditional AND (&amp;) instead of the conditional version (&amp;&am..." /> <script id="webpack-public-path" type="text/uri-list">https://cdn.sstatic.net/</script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script defer src="https://cdn.sstatic.net/Js/third-party/npm/@stackoverflow/stacks/dist/js/stacks.min.js?v=90a447add688"></script> <script src="https://cdn.sstatic.net/Js/stub.en.js?v=30464efc364f"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/stacks.css?v=bd2aba62c5a4"> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=cc49ce762956"> <link rel="alternate" type="application/atom+xml" title="Feed for question 'What are the cases in which it is better to use unconditional AND (& instead of &&)'" href="/feeds/question/11411907"> <script> StackExchange.ready(function () { StackExchange.using("snippets", function () { StackExchange.snippets.initSnippetRenderer(); }); StackExchange.using("postValidation", function () { StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer'); }); StackExchange.question.init({showAnswerHelp:true,showTrendingSortLaunchPopover:false,showTrendingSortPostLaunchPopover:false,totalCommentCount:1,shownCommentCount:1,enableTables:true,questionId:11411907}); styleCode(); StackExchange.realtime.subscribeToQuestion('1', '11411907'); StackExchange.using("gps", function () { StackExchange.gps.trackOutboundClicks('#content', '.js-post-body'); }); }); </script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7"> <script type="application/json" data-role="module-args" data-module-name="Shared/options.mod">{"options":{"locale":"en","serverTime":1739920671,"routeName":"Questions/Show","stackAuthUrl":"https://stackauth.com","networkMetaHostname":"meta.stackexchange.com","site":{"name":"Stack Overflow","description":"Q\u0026A for professional and enthusiast programmers","isNoticesTabEnabled":true,"enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"id":1,"cookieDomain":".stackoverflow.com","childUrl":"https://meta.stackoverflow.com","negativeVoteScoreFloor":null,"enableSocialMediaInSharePopup":true,"protocol":"https"},"user":{"fkey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","tid":"1c904cd0-5617-48ef-8e7f-62520647702d","rep":0,"isAnonymous":true,"isAnonymousNetworkWide":true},"events":{"postType":{"question":1},"postEditionSection":{"title":1,"body":2,"tags":3}}}}</script> <script type="application/json" data-role="module-args" data-module-name="Shared/settings.mod">{"settings":{"image":{"maxImageUploadSizeInBytesAnimatedGif":2097152,"maxImageUploadSizeInBytes":10485760},"site":{"enableUserHovercards":true,"forceHttpsImages":true,"enableImageHttps":true,"stacksEditorPreviewEnabled":true,"allowImageUploads":true,"styleCode":true},"mentions":{"maxNumUsersInDropdown":50},"markdown":{"enableTables":true},"questionLinkTitleReplacement":{"maxReplacementsPerSite":20,"maxNumberOfSitesProcessed":10},"snippets":{"renderDomain":"stacksnippets.net","snippetsEnabled":true},"search":{},"tags":{},"questions":{"enableSavesFeature":true,"questionTitleLengthStartLiveWarningChars":50,"enableQuestionTitleLengthLiveWarning":true,"maxTitleSize":150},"legal":{"oneTrustTCFConfigId":"c3d9f1e3-55f3-4eba-b268-46cee4c6789c","useCustomConsent":false},"subscriptions":{"defaultBasicMaxTrueUpSeats":250,"defaultFreemiumMaxTrueUpSeats":50,"defaultMaxTrueUpSeats":1000},"comments":{},"flags":{"allowRetractingFlags":true,"allowRetractingCommentFlags":true},"paths":{"jQueryUICSSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/themes/smoothness/jquery-ui.css","jQueryUIJSPath":"https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"},"userMessaging":{"showNewFeatureNotice":true},"elections":{"opaVoteResultsBaseUrl":"https://www.opavote.com/results/"},"intercom":{"appId":"inf0secd"},"accounts":{"currentPasswordRequiredForChangingStackIdPassword":true},"auth":{"oauthInPopup":true}}}</script> <script>StackExchange.init();</script> <script> StackExchange.using.setCacheBreakers({"Js/adops.en.js":"6da43f5e0a84","Js/ask.en.js":"","Js/begin-edit-event.en.js":"20edbaccceae","Js/copy-transpiled.en.js":"f48f8f039185","Js/events.en.js":"","Js/explore-qlist.en.js":"ee2a4f8c3992","Js/full-anon.en.js":"427705904ec4","Js/full.en.js":"296fbe64881a","Js/highlightjs-loader.en.js":"a3e36fe85053","Js/inline-tag-editing.en.js":"8517756a2cb6","Js/keyboard-shortcuts.en.js":"c255a5a5979b","Js/markdown-it-loader.en.js":"781aa77e9602","Js/mentions-transpiled.en.js":"bcadb48d3570","Js/moderator.en.js":"a9347e812307","Js/postCollections-transpiled.en.js":"9f7a87e8cf0d","Js/post-validation.en.js":"44d59ccfc490","Js/question-editor.en.js":"","Js/review-v2-transpiled.en.js":"c9e05881f8ab","Js/revisions.en.js":"9dd135bb585f","Js/stacks-editor.en.js":"cf77c9d2187c","Js/tageditor.en.js":"5b8f289d02ef","Js/tageditornew.en.js":"ca426894aed0","Js/tagsuggestions.en.js":"762b96a1ae1f","Js/unlimited-transpiled.en.js":"8713a979101d","Js/wmd.en.js":"eef1c2cfa021","Js/snippet-javascript-codemirror.en.js":"0f42dbb990fa"}); StackExchange.using("gps", function() { StackExchange.gps.init(false); }); </script> <noscript id="noscript-css"><style>body,.s-topbar{margin-top:1.9em}</style></noscript> </head> <body class="question-page unified-theme"> <div id="signup-modal-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/signup-modal/index.mod">{"ContainerElementId":"signup-modal-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","TriggerEvent":"signupModalShow","OauthInPopup":true,"ReturnUrl":"https://stackoverflow.com/questions/11411907/what-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of/11412121","ReturnUrlForPopup":"https://stackoverflow.com/users/after-signup/oauth-only","SiteName":"Stack Overflow","SiteLogoPath":"https://cdn.sstatic.net/Sites/stackoverflow/Img/icon-48.png?v=b7e36f88ff92","AuthProviders":["Google","GitHub"],"ParentSiteUrl":"","IsInitiallyVisible":false}</script> <script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=ac1681a633a2"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/8901.en.js?v=9ff34567d3a5"></script><script defer src="https://cdn.sstatic.net/Js/islands/signup-modal.en.js?v=47ec828efb46"></script> <script defer> dispatchEvent(new CustomEvent("openSignupModal")); </script> <div id="one-tap-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/one-tap/index.mod">{"ContainerElementId":"one-tap-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","GoogleClientId":"717762328687-iludtf96g1hinl76e4lc1b9a82g457nn.apps.googleusercontent.com","Autoselect":false,"ReturnUrl":"https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121"}</script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=ac1681a633a2"></script><script defer src="https://cdn.sstatic.net/Js/islands/one-tap.en.js?v=bc67e8c0f01e"></script> <div id="notify-container"></div> <div id="custom-header"></div> <header class="s-topbar ps-fixed t0 l0 js-top-bar"> <a href="#content" class="s-topbar--skip-link">Skip to main content</a> <div class="s-topbar--container"> <a href="#" class="s-topbar--menu-btn js-left-sidebar-toggle" role="menuitem" aria-haspopup="true" aria-controls="left-sidebar" aria-expanded="false"><span></span></a> <div class="topbar-dialog leftnav-dialog js-leftnav-dialog dno"> <div class="left-sidebar js-unpinned-left-sidebar" data-can-be="left-sidebar" data-is-here-when="sm"></div> </div> <a href="https://stackoverflow.com" class="s-topbar--logo js-gps-track" data-gps-track="top_nav.click({is_current:false, location:2, destination:8}); homelogo_nav.click({location:2})"> <span class="-img _glyph">Stack Overflow</span> </a> <ol class="s-navigation fw-nowrap" role="presentation"> <li class="md:d-none"> <a href="https://stackoverflow.co/" class="s-navigation--item js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:7})" data-ga="["top navigation","about menu click",null,null,null]">About</a> </li> <li> <button class="s-navigation--item js-gps-track" type="button" aria-controls="products-popover" aria-expanded="false" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.products.click({location:2, destination:1})" data-ga="["top navigation","products menu click",null,null,null]"> Products </button> </li> <li class="md:d-none"> <a href="https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai" class="s-navigation--item js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:10})" data-ga="["top navigation","learn more - overflowai",null,null,null]">OverflowAI</a> </li> </ol> <div class="s-popover ws2 mtn2 p0" id="products-popover" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <ol class="list-reset s-anchors s-anchors__inherit"> <li class="m6"> <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:3})" data-ga="["top navigation","teams submenu click",null,null,null]"> <span class="fs-body1 d-block">Stack Overflow for Teams</span> <span class="fs-caption d-block fc-black-400">Where developers & technologists share private knowledge with coworkers</span> </a> </li> <li class="m6"> <a href="https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:6})" data-ga="["top navigation","advertising submenu click",null,null,null]"> <span class="fs-body1 d-block">Advertising & Talent</span> <span class="fs-caption d-block fc-black-400">Reach devs & technologists worldwide about your product, service or employer brand</span> </a> </li> <li class="bt bc-black-200 pt6 px6 bbr-md"> <a href="https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:10})" data-ga="["top navigation","overflowai submenu click",null,null,null]"> <span class="fs-body1 d-block">OverflowAI</span> <span class="fs-caption d-block fc-black-400">GenAI features for Teams</span> </a> </li> <li class="pb6 px6 bbr-md"> <a href="https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:11})" data-ga="["top navigation","overflowapi submenu click",null,null,null]"> <span class="fs-body1 d-block">OverflowAPI</span> <span class="fs-caption d-block fc-black-400">Train & fine-tune LLMs</span> </a> </li> <li class="bt bc-black-200 py6 px6 bbr-md"> <a href="https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs" class="bar-sm p6 d-block h:bg-black-225 js-gps-track" data-gps-track="top_nav.products.click({location:2, destination:12})" data-ga="["top navigation","labs submenu click",null,null,null]"> <span class="fs-body1 d-block">Labs</span> <span class="fs-caption d-block fc-black-400">The future of collective knowledge sharing</span> </a> </li> <li class="bg-black-100 bt bc-black-200 py6 px6 bbr-md"> <a href="https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company" class="fc-black-400 d-block py6 px6 h:fc-black-600" data-ga="["top navigation","about submenu click",null,null,null]">About the company</a> <a href="https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog" class="fc-black-400 d-block py6 px6 h:fc-black-600" data-ga="["top navigation","blog submenu click",null,null,null]">Visit the blog</a> </li> </ol> </div> <form id="search" role="search" action=/search class="s-topbar--searchbar js-searchbar " autocomplete="off"> <div class="s-topbar--searchbar--input-group"> <input name="q" type="text" role="combobox" placeholder="Search…" value="" autocomplete="off" maxlength="240" class="s-input s-input__search js-search-field wmn1 " aria-label="Search" aria-controls="top-search" data-controller="s-popover" data-action="focus->s-popover#show" data-s-popover-placement="bottom-start" /> <svg aria-hidden="true" class="s-input-icon s-input-icon__search svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18zM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0"/></svg> <div class="s-popover p0 wmx100 wmn4 sm:wmn-initial js-top-search-popover" id="top-search" role="menu"> <div class="s-popover--arrow"></div> <div class="s-popover--content"> <div class="js-spinner p24 d-flex ai-center jc-center d-none"> <div class="s-spinner s-spinner__sm fc-orange-400"> <div class="v-visible-sr">Loading…</div> </div> </div> <span class="v-visible-sr js-screen-reader-info"></span> <div class="js-ac-results overflow-y-auto hmx3 d-none"></div> <div class="js-search-hints" aria-describedby="Tips for searching"></div> </div> </div> </div> </form> <nav class="h100 ml-auto overflow-x-auto pr12" aria-label="Topbar"> <ol class="s-topbar--content" role="menubar"> <li class="js-topbar-dialog-corral" role="presentation"> <div class="topbar-dialog siteSwitcher-dialog dno" role="menu"> <div class="header fw-wrap"> <h3 class="flex--item"> <a href="https://stackoverflow.com">current community</a> </h3> <div class="flex--item fl1"> <div class="ai-center d-flex jc-end"> <button class="js-close-button s-btn s-btn__muted p0 ml8 d-none sm:d-block" type="button" aria-label="Close" > <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9z"/></svg> </button> </div> </div> </div> <div class="modal-content bg-blue-200 current-site-container"> <ul class="current-site"> <li class="d-flex"> <div class="fl1"> <a href="https://stackoverflow.com" class="current-site-link d-flex gx8 site-link js-gps-track" data-id="1" data-gps-track="site_switcher.click({ item_type:3 })"> <div class="favicon favicon-stackoverflow site-icon flex--item" title="Stack Overflow"></div> <span class="flex--item fl1"> Stack Overflow </span> </a> </div> <div class="related-links"> <a href="https://stackoverflow.com/help" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:14 })">help</a> <a href="https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a> </div> </li> <li class="related-site d-flex"> <div class="L-shaped-icon-container"> <span class="L-shaped-icon"></span> </div> <a href="https://meta.stackoverflow.com" class="s-block-link px16 d-flex gx8 site-link js-gps-track" data-id="552" data-gps-track="site.switch({ target_site:552, item_type:3 }),site_switcher.click({ item_type:4 })"> <div class="favicon favicon-stackoverflowmeta site-icon flex--item" title="Meta Stack Overflow"></div> <span class="flex--item fl1"> Meta Stack Overflow </span> </a> </li> </ul> </div> <div class="header" id="your-communities-header"> <h3> your communities </h3> </div> <div class="modal-content" id="your-communities-section"> <div class="call-to-login"> <a href="https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list. </div> </div> <div class="header"> <h3><a href="https://stackexchange.com/sites">more stack exchange communities</a> </h3> <a href="https://stackoverflow.blog" class="float-right">company blog</a> </div> <div class="modal-content"> <div class="child-content"></div> </div> </div> </li> <li role="none"><button class="s-topbar--item s-btn s-btn__icon s-btn__muted d-none sm:d-inline-flex js-searchbar-trigger" role="menuitem" aria-label="Search" aria-haspopup="true" aria-controls="search" title="Click to show search"><svg aria-hidden="true" class="svg-icon iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="m18 16.5-5.14-5.18h-.35a7 7 0 1 0-1.19 1.19v.35L16.5 18zM12 7A5 5 0 1 1 2 7a5 5 0 0 1 10 0"/></svg></button></li> <li role="none"> <a href="https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121" class="s-topbar--item s-topbar--item__unset s-btn s-btn__outlined ws-nowrap js-gps-track" role="menuitem" rel="nofollow" data-gps-track="login.click" data-ga="["top navigation","login button click",null,null,null]">Log in</a> </li> <li role="none"><a href="https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121" class="s-topbar--item s-topbar--item__unset ml4 s-btn s-btn__filled ws-nowrap js-signup-button js-gps-track" role="menuitem" rel="nofollow" data-gps-track="signup.topbar.click" data-ga="["sign up","Sign Up Navigation","Header",null,null]">Sign up</a></li> </ol> </nav> </div> </header> <script> StackExchange.ready(function () { StackExchange.topbar.init(); }); StackExchange.scrollPadding.setPaddingTop(50, 10); </script> <div class="container"> <div id="homepage-wizard-container"></div> <script type="application/json" data-role="module-args" data-module-name="islands/homepage-wizard/index.mod">{"ContainerElementId":"homepage-wizard-container","FKey":"b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4","Tags":["javascript","python","java","c#","php","android","html","jquery","c++","css","ios","sql","mysql","r","reactjs","node.js","arrays","c","asp.net","json","python-3.x",".net","ruby-on-rails","sql-server","swift","django","angular","objective-c","excel","pandas","angularjs","regex","typescript","ruby","linux","ajax","iphone","vba","xml","laravel","spring","asp.net-mvc","database","wordpress","string","flutter","postgresql","mongodb","wpf","windows","amazon-web-services","xcode","bash","git","oracle-database","spring-boot","dataframe","azure","firebase","list","multithreading","docker","vb.net","react-native","eclipse","algorithm","powershell","macos","visual-studio","numpy","image","forms","scala","function","vue.js","performance","twitter-bootstrap","selenium","winforms","kotlin","loops","express","dart","hibernate","sqlite","matlab","python-2.7","shell","rest","apache","entity-framework","android-studio","csv","api","maven","linq","qt","dictionary","unit-testing","facebook","asp.net-core","tensorflow","apache-spark","file","swing","class","unity-game-engine","sorting","date","authentication","go","symfony","opencv","t-sql","matplotlib",".htaccess","google-chrome","for-loop","datetime","codeigniter","http","perl","validation","sockets","google-maps","object","uitableview","xaml","oop","if-statement","visual-studio-code","cordova","ubuntu","web-services","email","android-layout","github","elasticsearch","spring-mvc","kubernetes","selenium-webdriver","ms-access","user-interface","parsing","ggplot2","pointers","machine-learning","c++11","security","google-sheets","flask","google-apps-script","ruby-on-rails-3","nginx","templates","variables","exception","sql-server-2008","gradle","debugging","tkinter","listview","delphi","jpa","asynchronous","pdf","web-scraping","haskell","jsp","ssl","amazon-s3","google-cloud-platform","jenkins","testing","xamarin","wcf","npm","batch-file","generics","ionic-framework","network-programming","unix","recursion","google-app-engine","mongoose","visual-studio-2010",".net-core","android-fragments","assembly","animation","math","next.js","session","svg","hadoop","intellij-idea","curl","django-models","join","laravel-5","winapi","rust","url","heroku","http-redirect","tomcat","google-cloud-firestore","inheritance","webpack","keras","image-processing","asp.net-mvc-4","gcc","web","logging","dom","swiftui","matrix","pyspark","actionscript-3","button","post","firebase-realtime-database","optimization","jquery-ui","iis","cocoa","xpath","d3.js","firefox","javafx","internet-explorer","xslt","caching","select","asp.net-mvc-3","opengl","events","asp.net-web-api","plot","dplyr","magento","encryption","search","stored-procedures","amazon-ec2","ruby-on-rails-4","memory","audio","canvas","multidimensional-array","jsf","random","cookies","vector","redux","facebook-graph-api","input","flash","xamarin.forms","indexing","arraylist","ipad","cocoa-touch","data-structures","video","apache-kafka","model-view-controller","serialization","jdbc","woocommerce","routes","razor","awk","azure-devops","servlets","mod-rewrite","beautifulsoup","docker-compose","iframe","filter","excel-formula","aws-lambda","design-patterns","text","django-rest-framework","visual-c++","cakephp","mobile","android-intent","react-hooks","struct","methods","groovy","mvvm","ssh","lambda","checkbox","google-chrome-extension","ecmascript-6","time","installation","grails","sharepoint","cmake","spring-security","shiny","jakarta-ee","android-recyclerview","plsql","core-data","types","meteor","android-activity","sed","websocket","bootstrap-4","activerecord","graph","replace","scikit-learn","file-upload","group-by","vim","junit","deep-learning","boost","import","sass","memory-management","error-handling","async-await","eloquent","dynamic","soap","silverlight","dependency-injection","charts","layout","apache-spark-sql","deployment","browser","gridview","svn","while-loop","google-bigquery","vuejs2","ffmpeg","dll","highcharts","view","foreach","plugins","c#-4.0","makefile","redis","reporting-services","jupyter-notebook","server","merge","https","unicode","reflection","google-maps-api-3","twitter","oauth-2.0","extjs","pytorch","axios","terminal","pip","split","mysqli","cmd","django-views","encoding","automation","database-design","netbeans","collections","hash","build","data-binding","ember.js","tcp","sqlalchemy","pdo","apache-flex","concurrency","command-line","spring-data-jpa","entity-framework-core","printing","java-8","react-redux","jestjs","service","html-table","neo4j","ansible","lua","parameters","material-ui","module","visual-studio-2012","enums","promise","flexbox","outlook","webview","firebase-authentication","web-applications","uwp","jquery-mobile","utf-8","datatable","python-requests","parallel-processing","drop-down-menu","colors","scroll","hive","tfs","scipy","count","syntax","ms-word","twitter-bootstrap-3","ssis","google-analytics","three.js","fonts","graphql","constructor","powerbi","rxjs","file-io","paypal","discord","cassandra","socket.io","graphics","compiler-errors","gwt","react-router","nlp","solr","backbone.js","url-rewriting","datatables","memory-leaks","datagridview","oauth","drupal","terraform","oracle11g","zend-framework","neural-network","knockout.js","django-forms","triggers","interface","google-api","angular-material","casting","jmeter","linked-list","proxy","path","timer","django-templates","arduino","orm","directory","parse-platform","cron","visual-studio-2015","windows-phone-7","push-notification","conditional-statements","primefaces","functional-programming","pagination","model","jar","xamarin.android","hyperlink","uiview","visual-studio-2013","gitlab","vbscript","google-cloud-functions","azure-active-directory","jwt","download","swift3","sql-server-2005","process","configuration","rspec","properties","pygame","combobox","callback","windows-phone-8","safari","linux-kernel","permissions","scrapy","raspberry-pi","scripting","emacs","clojure","scope","io","x86","compilation","responsive-design","mongodb-query","nhibernate","angularjs-directive","request","expo","bluetooth","3d","dns","binding","reference","azure-functions","discord.js","architecture","playframework","pyqt","version-control","doctrine-orm","package","pycharm","get","sql-server-2012","rubygems","f#","autocomplete","datepicker","openssl","kendo-ui","tree","jackson","controller","yii","nested","grep","xamarin.ios","static","statistics","dockerfile","transactions","null","datagrid","active-directory","uiviewcontroller","phpmyadmin","webforms","discord.py","notifications","computer-vision","sas","duplicates","mocking","youtube","nullpointerexception","yaml","menu","sum","bitmap","electron","asp.net-mvc-5","visual-studio-2008","time-series","yii2","jsf-2","css-selectors","android-listview","stl","floating-point","blazor","cryptography","ant","stream","hashmap","character-encoding","msbuild","sdk","asp.net-core-mvc","google-drive-api","selenium-chromedriver","jboss","joomla","navigation","cors","devise","anaconda","frontend","background","camera","pyqt5","multiprocessing","binary","cuda","linq-to-sql","iterator","mariadb","onclick","ios7","plotly","rabbitmq","android-asynctask","android-jetpack-compose","microsoft-graph-api","tabs","laravel-4","insert","amazon-dynamodb","uicollectionview","environment-variables","linker","console","xsd","coldfusion","upload","continuous-integration","ftp","textview","opengl-es","operating-system","mockito","localization","vuejs3","xml-parsing","macros","formatting","json.net","kivy","type-conversion","data.table","timestamp","calendar","integer","segmentation-fault","android-ndk","drag-and-drop","prolog","char","crash","jasmine","automated-tests","dependencies","geometry","android-gradle-plugin","itext","firebase-cloud-messaging","header","sprite-kit","mfc","fortran","attributes","nosql","nuxt.js","format","nestjs","azure-pipelines","odoo","jquery-plugins","db2","leaflet","jenkins-pipeline","event-handling","postman","flutter-layout","annotations","julia","keyboard","textbox","arm","visual-studio-2017","gulp","libgdx","stripe-payments","xampp","synchronization","crystal-reports","timezone","azure-web-app-service","dom-events","android-emulator","swagger","uikit","wso2","sequelize.js","aggregation-framework","namespaces","uiscrollview","jvm","chart.js","com","google-sheets-formula","subprocess","geolocation","centos","webdriver","html5-canvas","widget","dialog","garbage-collection","numbers","concatenation","snowflake-cloud-data-platform","sql-update","qml","windows-10","set","mapreduce","smtp","tuples","ionic2","java-stream","rotation","modal-dialog","android-edittext","spring-data","http-headers","radio-button","doctrine","nuget","grid","sonarqube","lucene","xmlhttprequest","internationalization","listbox","components","initialization","switch-statement","google-play","boolean","apache-camel","serial-port","ldap","ios5","youtube-api","return","gdb","pivot","latex","eclipse-plugin","frameworks","tags","containers","dataset","github-actions","asp-classic","foreign-keys","subquery","label","copy","uinavigationcontroller","google-cloud-storage","delegates","c++17","struts2","migration","base64","protractor","sql-server-2008-r2","queue","find","uibutton","embedded","arguments","append","composer-php","jaxb","zip","stack","cucumber","autolayout","ide","popup","entity-framework-6","iteration","windows-7","airflow","r-markdown","ssl-certificate","vb6","gmail","jqgrid","hover","udp","g++","tailwind-css"],"TriggerEvent":"homepageWizardShow","OauthInPopup":true,"ReturnUrl":"https://stackoverflow.com","ReturnUrlForPopup":"https://stackoverflow.com/users/after-signup/oauth-only","ThemePreferenceFlags":0}</script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=ac1681a633a2"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/2784.en.js?v=414ac3934ec2"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/8901.en.js?v=9ff34567d3a5"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/6719.en.js?v=5cd743a95ced"></script><script defer src="https://cdn.sstatic.net/Js/islands/homepage-wizard.en.js?v=1dc402690a54"></script> <div id="left-sidebar" data-is-here-when="md lg" class="left-sidebar js-pinned-left-sidebar ps-relative"> <div class="left-sidebar--sticky-container js-sticky-leftnav"> <nav aria-label="Primary"> <ol class="nav-links"> <li> <ol class="nav-links"> <li class="ps-relative" aria-current="false"> <a href="/" class="s-block-link pl8 js-homepage-wizard-link js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:8, has_activity_notification:False});home_nav.click({location:2})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconHome" width="18" height="18" viewBox="0 0 18 18"><path d="M15 10v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5H0l9-9 9 9zm-8 1v6h4v-6z"/></svg> <span class="-link--channel-name pl6">Home</span> </div> </a> </li> <li class="ps-relative youarehere" aria-current="true"> <a id="nav-questions" href="/questions" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: true, location:2, destination:1, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconQuestion" width="18" height="18" viewBox="0 0 18 18"><path d="m4 15-3 3V4c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v9c0 1.09-.91 2-2 2zm7.75-3.97c.72-.83.98-1.86.98-2.94 0-1.65-.7-3.22-2.3-3.83a4.4 4.4 0 0 0-3.02 0 3.8 3.8 0 0 0-2.32 3.83q0 1.93 1.03 3a3.8 3.8 0 0 0 2.85 1.07q.94 0 1.71-.34.97.66 1.06.7.34.2.7.3l.59-1.13a5 5 0 0 1-1.28-.66m-1.27-.9a5 5 0 0 0-1.5-.8l-.45.9q.5.18.98.5-.3.1-.65.11-.92 0-1.52-.68c-.86-1-.86-3.12 0-4.11.8-.9 2.35-.9 3.15 0 .9 1.01.86 3.03-.01 4.08"/></svg> <span class="-link--channel-name pl6">Questions</span> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a href="/tags" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:2, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconTags" width="18" height="18" viewBox="0 0 18 18"><path d="M9.24 1a3 3 0 0 0-2.12.88l-5.7 5.7a2 2 0 0 0-.38 2.31 3 3 0 0 1 .67-1.01l6-6A3 3 0 0 1 9.83 2H14a3 3 0 0 1 .79.1A2 2 0 0 0 13 1z" opacity=".4"/><path d="M9.83 3a2 2 0 0 0-1.42.59l-6 6a2 2 0 0 0 0 2.82L6.6 16.6a2 2 0 0 0 2.82 0l6-6A2 2 0 0 0 16 9.17V5a2 2 0 0 0-2-2zM12 9a2 2 0 1 1 0-4 2 2 0 0 1 0 4"/></svg> <span class="-link--channel-name pl6">Tags</span> </div> </a> </li> <li class="pb24"></li> <li class="ps-relative" aria-current="false"> <a id="nav-users" href="/users" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:3, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconPeople" width="18" height="18" viewBox="0 0 18 18"><path d="M17 14c0 .44-.45 1-1 1H9a1 1 0 0 1-1-1H2c-.54 0-1-.56-1-1 0-2.63 3-4 3-4s.23-.4 0-1c-.84-.62-1.06-.59-1-3s1.37-3 2.5-3 2.44.58 2.5 3-.16 2.38-1 3c-.23.59 0 1 0 1s1.55.71 2.42 2.09c.78-.72 1.58-1.1 1.58-1.1s.23-.4 0-1c-.84-.61-1.06-.58-1-3s1.37-3 2.5-3 2.44.59 2.5 3c.05 2.42-.16 2.39-1 3-.23.6 0 1 0 1s3 1.38 3 4"/></svg> <span class="-link--channel-name pl6">Users</span> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a id="nav-companies" href="https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav" class="s-block-link pl8 js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:12, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="svg-icon iconIndustry" width="18" height="18" viewBox="0 0 18 18"><path d="M10 16v-4H8v4H2V4c0-1.1.9-2 2-2h6c1.09 0 2 .91 2 2v2h2c1.09 0 2 .91 2 2v8zM4 4v2h2V4zm0 4v2h2V8zm4-4v2h2V4zm0 4v2h2V8zm-4 4v2h2v-2zm8 0v2h2v-2zm0-4v2h2V8z"/></svg> <span class="-link--channel-name pl6">Companies</span> </div> </a> </li> <li class="ml8 mt32 mb8"> <a href="javascript:void(0)" class="s-link s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine" role="button" aria-controls="popover-labs-left-nav" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="top" data-s-popover-toggle-class="is-selected" > <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Labs</div> <div class="flex--item px12"> <svg aria-hidden="true" class="svg-icon iconInfoSm" width="14" height="14" viewBox="0 0 14 14"><path d="M7 1a6 6 0 1 1 0 12A6 6 0 0 1 7 1m1 10V6H6v5zm0-6V3H6v2z"/></svg> </div> </a> </li> <li class="ps-relative" aria-current="false"> <a id="nav-labs-discussions" href="/beta/discussions" class="s-block-link pl8 ai-center js-gps-track nav-links--link -link__with-icon" data-gps-track="top_nav.click({is_current: false, location:2, destination:24, has_activity_notification:False})" aria-controls="" data-controller=" " data-s-popover-placement="right" aria-current="false" data-s-popover-auto-show="true" data-s-popover-hide-on-outside-click="never" > <div class="d-flex ai-center"> <svg aria-hidden="true" class="w16 svg-icon iconMessage" width="18" height="18" viewBox="0 0 18 18"><path d="M5 7a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1m1 2a1 1 0 1 0 0 2h4a1 1 0 1 0 0-2zm-5 9V4c0-1.1.9-2 2-2h12c1.09 0 2 .91 2 2v9c0 1.09-.91 2-2 2H4.5zm2.76-5h11.23v-.01H15V4H3v9.65z"/></svg> <span class="-link--channel-name pl6">Discussions</span> </div> </a> </li> <li class="ml8 mt32 mb4"> <div class="d-flex jc-space-between ai-center"> <a class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine" href="javascript:void(0)" role="button" aria-controls="popover-discover-collectives" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="top" data-s-popover-toggle-class="is-selected" data-gps-track="top_nav.click({is_current:false, location:2, destination:17})" > <div class="flex--item fl-grow1 tt-uppercase fc-black-600 fw-bold">Collectives</div> <div class="flex--item px12 js-collectives-navcta-toggle"> <svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8z"/></svg> </div> </a> </div> </li> <li class="ps-relative js-collectives-navcta-toggle"> <p class="fs-fine pr8 pl8 pt4 fc-black-400"> Communities for your favorite technologies. <a href="/collectives-all" class="s-link s-link__grayscale s-link__underlined fw-bold">Explore all Collectives</a> </p> </li> </ol> </li> <li class="js-freemium-cta ps-relative mt32 mb8"> <div class="fs-fine tt-uppercase fc-black-600 fw-bold ml8 mt16 mb8">Teams</div> <div class="px12 pt12 pb4 mb12 fc-medium overflow-hidden"> <img class="wmx100 mx-auto mb12 h-auto d-block" width="151" height="24" src="https://cdn.sstatic.net/Img/teams/teams-promo.svg?v=e507948b81bf" alt=""> <p class="fs-fine"> Ask questions, find answers and collaborate at work with Stack Overflow for Teams. </p> <a href="https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams" class="w100 s-btn s-btn__filled s-btn__xs bg-orange-400 h:bg-orange-500 js-gps-track pt8 pr7 pb6 pl7" data-gps-track="teams.create.left-sidenav.click({ Action: 6 })" data-ga="["teams left navigation - anonymous","left nav free cta","stackoverflow.com/teams/create/free",null,null]">Try Teams for free</a> <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams" class="w100 s-btn s-btn__muted s-btn__xs mt1 js-gps-track" data-gps-track="teams.create.left-sidenav.click({ Action: 5 })" data-ga="["teams left navigation - anonymous","left nav free cta","stackoverflow.com/teams",null,null]">Explore Teams</a> </div> </li> <li class="d-flex ai-center jc-space-between ml8 mt32 mb8 js-create-team-cta d-none"> <a href="javascript:void(0)" class="s-link d-flex fl-grow1 fc-black-400 h:fc-black-600 fs-fine js-gps-track" role="button" aria-controls="popover-teams-create-cta" data-controller="s-popover" data-action="s-popover#toggle" data-s-popover-placement="bottom-start" data-s-popover-toggle-class="is-selected" data-gps-track="teams.create.left-sidenav.click({ Action: ShowInfo })" data-ga="["teams left navigation - anonymous","left nav show teams info",null,null,null]" > <div class="flex--item fl-grow1 fc-black-600 fw-bold tt-uppercase">Teams</div> <div class="flex--item px12"> <svg aria-hidden="true" class="svg-icon iconPlusSm" width="14" height="14" viewBox="0 0 14 14"><path d="M8 2H6v4H2v2h4v4h2V8h4V6H8z"/></svg> </div> </a> </li> <li class="ps-relative js-create-team-cta d-none"> <p class="fs-fine pr8 pl8 pb4 fc-black-400"> Ask questions, find answers and collaborate at work with Stack Overflow for Teams. <a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact" class="s-link s-link__grayscale s-link__underlined fw-bold">Explore Teams</a> </p> </li> </ol> </nav> </div> <div class="s-popover ws2" id="popover-discover-collectives" role="menu"> <div class="s-popover--arrow"></div> <div> <svg aria-hidden="true" class="fc-orange-400 float-right ml24 svg-spot spotCollective" width="48" height="48" viewBox="0 0 48 48"><path d="M25.5 7a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5M14 18.25c0-.69.56-1.25 1.25-1.25h22.5c.69 0 1.25.56 1.25 1.25V37.5a1 1 0 0 1-1.6.8l-4.07-3.05a1.3 1.3 0 0 0-.75-.25H15.25c-.69 0-1.25-.56-1.25-1.25zM7 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M25.5 48a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5M48 24.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0" opacity=".2"/><path d="M21 3.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0M24.5 2a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M0 23.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0M3.5 22a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3M21 44.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0m3.5-1.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3m20-23a3.5 3.5 0 1 0 0 7 3.5 3.5 0 0 0 0-7M43 23.5a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0m-23.23-3.14a1 1 0 0 1-.13 1.4l-2.08 1.74 2.08 1.73a1 1 0 1 1-1.28 1.54l-2.42-2.02a1.63 1.63 0 0 1 0-2.5l2.42-2.02a1 1 0 0 1 1.4.13m7.6 1.41a1 1 0 1 1 1.28-1.54l2.42 2.02c.78.65.78 1.85 0 2.5l-2.42 2.02a1 1 0 1 1-1.28-1.54l2.08-1.73zM24.12 18a1 1 0 0 1 .87 1.12l-1 8a1 1 0 1 1-1.98-.24l1-8a1 1 0 0 1 1.11-.87M12.25 13C11.01 13 10 14 10 15.25v15.5c0 1.24 1 2.25 2.25 2.25h17.33q.09 0 .15.05l4.07 3.05a2 2 0 0 0 3.2-1.6V15.25c0-1.24-1-2.25-2.25-2.25zM12 15.25q.02-.23.25-.25h22.5q.23.02.25.25V34.5l-4.07-3.05q-.6-.45-1.35-.45H12.25a.25.25 0 0 1-.25-.25zm7.24-10.68a1 1 0 1 0-.48-1.94A22 22 0 0 0 2.91 17.7a1 1 0 1 0 1.92.58 20 20 0 0 1 14.4-13.72m11.06-1.65a1 1 0 0 0-.58 1.92c6.45 1.92 11.54 7 13.46 13.46a1 1 0 1 0 1.92-.58 22 22 0 0 0-14.8-14.8M4.57 28.76a1 1 0 0 0-1.94.48 22 22 0 0 0 16.13 16.13 1 1 0 1 0 .48-1.94A20 20 0 0 1 4.57 28.76m40.8.48a1 1 0 1 0-1.94-.48 20 20 0 0 1-13.72 14.41 1 1 0 0 0 .58 1.92 22 22 0 0 0 15.08-15.85"/></svg> <h5 class="pt4 fw-bold">Collectives™ on Stack Overflow</h5> <p class="my16 fs-caption fc-black-500">Find centralized, trusted content and collaborate around the technologies you use most.</p> <a href="/collectives" class="js-gps-track s-btn s-btn__filled s-btn__xs" data-gps-track="top_nav.click({is_current:false, location:2, destination:18})"> Learn more about Collectives </a> </div> </div> <div class="s-popover ws2" id="popover-teams-create-cta" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <div class="ps-relative overflow-hidden"> <p class="mb2"><strong>Teams</strong></p> <p class="mb12 fs-caption fc-black-400">Q&A for work</p> <p class="mb12 fs-caption fc-black-500">Connect and share knowledge within a single location that is structured and easy to search.</p> <a href="https://stackoverflow.co/teams/" class="js-gps-track s-btn s-btn__filled s-btn__xs" data-gps-track="teams.create.left-sidenav.click({ Action: CtaClick })" data-ga="["teams left navigation - anonymous","left nav cta","stackoverflow.com/teams",null,null]"> Learn more about Teams </a> </div> <div class="ps-absolute t8 r8"> <svg aria-hidden="true" class="fc-orange-400 svg-spot spotPeople" width="48" height="48" viewBox="0 0 48 48"><path d="M13.5 28a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9M7 30a1 1 0 0 1 1-1h11a1 1 0 0 1 1 1v5h11v-5a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v10a2 2 0 0 1-2 2H33v5a1 1 0 0 1-1 1H20a1 1 0 0 1-1-1v-5H8a1 1 0 0 1-1-1zm25-6.5a4.5 4.5 0 1 0 9 0 4.5 4.5 0 0 0-9 0M24.5 34a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9" opacity=".2"/><path d="M16.4 26.08A6 6 0 1 0 7.53 26C5.64 26.06 4 27.52 4 29.45V40a1 1 0 0 0 1 1h9a1 1 0 1 0 0-2h-4v-7a1 1 0 1 0-2 0v7H6v-9.55c0-.73.67-1.45 1.64-1.45H16a1 1 0 0 0 .4-1.92M12 18a4 4 0 1 1 0 8 4 4 0 0 1 0-8m16.47 14a6 6 0 1 0-8.94 0A3.6 3.6 0 0 0 16 35.5V46a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1V35.5c0-1.94-1.64-3.42-3.53-3.5M20 28a4 4 0 1 1 8 0 4 4 0 0 1-8 0m-.3 6h8.6c1 0 1.7.75 1.7 1.5V45h-2v-7a1 1 0 1 0-2 0v7h-4v-7a1 1 0 1 0-2 0v7h-2v-9.5c0-.75.7-1.5 1.7-1.5M42 22c0 1.54-.58 2.94-1.53 4A3.5 3.5 0 0 1 44 29.45V40a1 1 0 0 1-1 1h-9a1 1 0 1 1 0-2h4v-7a1 1 0 1 1 2 0v7h2v-9.55A1.5 1.5 0 0 0 40.48 28H32a1 1 0 0 1-.4-1.92A6 6 0 1 1 42 22m-2 0a4 4 0 1 0-8 0 4 4 0 0 0 8 0"/><g opacity=".35"><path d="M17 10a1 1 0 011-1h12a1 1 0 110 2H18a1 1 0 01-1-1m1-5a1 1 0 100 2h12a1 1 0 100-2zM14 1a1 1 0 00-1 1v12a1 1 0 001 1h5.09l4.2 4.2a1 1 0 001.46-.04l3.7-4.16H34a1 1 0 001-1V2a1 1 0 00-1-1zm1 12V3h18v10h-5a1 1 0 00-.75.34l-3.3 3.7-3.74-3.75a1 1 0 00-.71-.29z"/></g></svg> </div> </div> <div class="s-popover ws2" id="popover-labs-left-nav" role="menu" aria-hidden="true"> <div class="s-popover--arrow"></div> <svg aria-hidden="true" class="fc-black-600 mb8 svg-icon iconLabsAltSm" width="42" height="18" viewBox="0 0 42 18"><path fill="var(--black-600)" d="M11.5 13.62c0 .21-.17.38-.37.38H5.36a.37.37 0 0 1-.37-.38V4.38c0-.21.17-.38.37-.38h1.26c.2 0 .37.17.37.38v7.6h4.14c.2 0 .37.18.37.38zm9.43.22a.4.4 0 0 1-.3.16h-1.5q-.25-.01-.36-.25l-.55-1.7h-3.1l-.56 1.7a.4.4 0 0 1-.35.25h-1.5a.38.38 0 0 1-.35-.5l3.39-9.25c.05-.15.2-.25.35-.25h1.13q.26.01.36.25l3.39 9.24q.06.19-.05.35m-4.16-7.39-1.21 3.53h2.26zm13.34 5.71a.37.37 0 0 0 0 .53A4.5 4.5 0 0 0 33.59 14c1.02 0 1.92-.27 2.58-.79a2.8 2.8 0 0 0 1.07-2.25c0-.86-.27-1.62-.87-2.15-.46-.4-1-.63-1.89-.76l-1.04-.16a2 2 0 0 1-.83-.33q-.22-.19-.22-.57 0-.46.3-.73c.2-.18.53-.32 1-.32.7 0 1.25.15 1.72.6.14.14.37.14.52 0l.88-.87a.37.37 0 0 0-.01-.53A4.2 4.2 0 0 0 33.72 4c-1.01 0-1.87.3-2.48.84a3 3 0 0 0-.93 2.2q-.02 1.24.78 2.01.72.66 1.93.83l1.07.15c.5.07.65.15.8.29q.23.2.24.67-.01.5-.35.73-.34.29-1.16.3c-.87 0-1.49-.19-2.07-.76a.37.37 0 0 0-.52 0zM22.37 14a.37.37 0 0 1-.37-.38V4.38c0-.21.17-.38.37-.38h3.54q1.4 0 2.26.78c.56.52.86 1.26.86 2.13 0 .84-.37 1.52-.87 1.95A2.6 2.6 0 0 1 29.17 11q0 1.42-.9 2.23c-.56.51-1.34.76-2.22.76zm3.54-1.98c.96 0 .96-1 .96-1s0-1.02-.96-1.02H24v2.02zm-.11-4.06c1.07 0 1.07-1.02 1.07-1.02s0-1.01-1.07-1.01H24v2.03zM0 4v10a4 4 0 0 0 4 4h34a4 4 0 0 0 4-4V4a4 4 0 0 0-4-4H4a4 4 0 0 0-4 4m4-2h34a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4c0-1.1.9-2 2-2"/></svg> <p class="fs-caption">Get early access and see previews of new features.</p> <a class="s-btn s-btn__filled s-btn__xs s-btn__icon fs-fine" href="https://stackoverflow.co/labs/"><svg aria-hidden="true" class="svg-icon iconShareSm" width="14" height="14" viewBox="0 0 14 14"><path d="M5 1H3a2 2 0 0 0-2 2v8c0 1.1.9 2 2 2h8a2 2 0 0 0 2-2V9h-2v2H3V3h2zm2 0h6v6h-2V4.5L6.5 9 5 7.5 9.5 3H7z"/></svg> Learn more about Labs</a> </div> </div> <div id="content" class="snippet-hidden"> <div itemprop="mainEntity" itemscope itemtype="https://schema.org/Question"> <link itemprop="image" href="https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a"> <div class="inner-content clearfix"> <div id="question-header" class="d-flex sm:fd-column"> <h1 itemprop="name" class="fs-headline1 ow-break-word mb8 flex--item fl1"><a href="/questions/11411907/what-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of" class="question-hyperlink">What are the cases in which it is better to use unconditional AND (& instead of &&)</a></h1> <div class="ml12 aside-cta flex--item sm:ml0 sm:mb12 sm:order-first d-flex jc-end"> <div class="ml12 aside-cta flex--item print:d-none"> <a href="/questions/ask" class="ws-nowrap s-btn s-btn__filled"> Ask Question </a> </div> </div> </div> <div class="d-flex fw-wrap pb8 mb16 bb bc-black-200"> <div class="flex--item ws-nowrap mr16 mb8" title="2012-07-10 11:02:30Z"> <span class="fc-black-400 mr2">Asked</span> <time itemprop="dateCreated" datetime="2012-07-10T11:02:30">12 years, 7 months ago</time> </div> <div class="flex--item ws-nowrap mr16 mb8"> <span class="fc-black-400 mr2">Modified</span> <a href="?lastactivity" class="s-link s-link__inherit" title="2012-08-20 09:19:41Z">12 years, 6 months ago</a> </div> <div class="flex--item ws-nowrap mb8" title="Viewed 3,733 times"> <span class="fc-black-400 mr2">Viewed</span> 4k times </div> </div> <div id="mainbar" role="main" aria-label="question and answers"> <div class="question js-question" data-questionid="11411907" data-position-on-page="0" data-score="49" id="question"> <style> </style> <div class="js-zone-container zone-container-main"> <div id="dfp-tlb" class="everyonelovesstackoverflow everyoneloves__top-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <div class="post-layout "> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11411907" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11411907" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This question shows research effort; it is useful and clear" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:cba2ba201037bb82,10:1739920671,16:304511fad3f44ecb,8:11411907,7dfb96a1d06b4dc2211d2ecbbed089992e37a790a56fabb210ab90f699b7a3be" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="49"> 49 </div> <button class="js-vote-down-btn js-vote-down-question flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This question does not show any research effort; it is unclear or not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:c6497b6514ef1104,10:1739920671,16:84a61554720bcb90,8:11411907,2c34060343f36998da06e1e6ed27974da2bc89e83edd3ff2d29cdfd3e6f0f16b" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11411907" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this question." data-is-saved="false" aria-label="Save" data-post-id="11411907" data-post-type-id="1" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11411907/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I'd like to know some cases in Java (or more generally: in programming) when it is preferred in boolean expressions to use the unconditional <code>AND</code> (<code>&</code>) instead of the conditional version (<code>&&</code>).</p> <p>I know how they work, but I cannot think about a case when use the single <code>&</code> is worth it.</p> </div> <div class="mt24 mb12"> <div class="post-taglist d-flex gs4 gsy fd-column"> <div class="d-flex ps-relative fw-wrap"> <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/java" class="s-tag post-tag" title="show questions tagged 'java'" aria-label="show questions tagged 'java'" rel="tag" aria-labelledby="tag-java-tooltip-container" data-tag-menu-origin="Unknown">java</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/optimization" class="s-tag post-tag" title="show questions tagged 'optimization'" aria-label="show questions tagged 'optimization'" rel="tag" aria-labelledby="tag-optimization-tooltip-container" data-tag-menu-origin="Unknown">optimization</a></li></ul> </div> </div> </div> <div class="mb0 "> <div class="mt16 d-flex gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="flex--item mr16 fl1 w96"> <div class="js-post-menu pt2" data-post-id="11411907" data-post-type-id="1"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/q/11411907" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this question" data-gps-track="post.click({ item: 2, priv: 0, post_type: 1 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this question" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="question" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="1" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11411907/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 1 })" title="">Improve this question</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11411907" class="s-btn s-btn__link js-follow-post js-follow-question js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 1 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this question to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:bc6151b431a1fd99,10:1739920671,16:829c2e2c5e3d24ec,8:11411907,241068034d37ed94bcab2329492505cc4436231cbfd905df0e54993c4ced8880" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11411907/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 1 })">edited <span title='2012-07-10 16:38:23Z' class='relativetime'>Jul 10, 2012 at 16:38</span></a> </div> </div> <div class="user-gravatar32"> <a href="/users/36464/muhammad-hasan-khan"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/6742132944d71304301d71dc832cdf12?s=64&d=identicon&r=PG" alt="Muhammad Hasan Khan's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details"> <a href="/users/36464/muhammad-hasan-khan" dir="auto">Muhammad Hasan Khan</a> <div class="-flair"> <span class="reputation-score" title="reputation score 35,136" dir="ltr">35.1k</span><span title="16 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">16</span></span><span class="v-visible-sr">16 gold badges</span><span title="92 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">92</span></span><span class="v-visible-sr">92 silver badges</span><span title="132 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">132</span></span><span class="v-visible-sr">132 bronze badges</span> </div> </div> </div> </div> <div class="post-signature owner flex--item"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> asked <span title='2012-07-10 11:02:30Z' class='relativetime'>Jul 10, 2012 at 11:02</span> </div> </div> <div class="user-gravatar32"> <a href="/users/1421864/luigi-massa-gallerano"><div class="gravatar-wrapper-32"><img src="https://i.sstatic.net/zRGy8.jpg?s=64" alt="Luigi Massa Gallerano's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/1421864/luigi-massa-gallerano" dir="auto">Luigi Massa Gallerano</a><span class="d-none" itemprop="name">Luigi Massa Gallerano</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">2,357</span><span title="4 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">4</span></span><span class="v-visible-sr">4 gold badges</span><span title="23 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">23</span></span><span class="v-visible-sr">23 silver badges</span><span title="25 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">25</span></span><span class="v-visible-sr">25 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11411907" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11411907" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-15071323" class="comment js-comment " data-comment-id="15071323" data-comment-owner-id="309412" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">possible duplicate of <a href="http://stackoverflow.com/questions/7331686/why-and-not">Why && and not &</a></span> <div class="d-inline-flex ai-center"> – <a href="/users/309412/lie-ryan" title="64,875 reputation" class="comment-user">Lie Ryan</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-11 03:35:17Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 11, 2012 at 3:35</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11411907" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> <script defer src="https://cdn.sstatic.net/Js/webpack-chunks/svelte.en.js?v=ac1681a633a2"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/stacks-svelte.en.js?v=585200d05e44"></script><script defer src="https://cdn.sstatic.net/Js/webpack-chunks/2784.en.js?v=414ac3934ec2"></script><script defer src="https://cdn.sstatic.net/Js/islands/comment-popover.en.js?v=96bfd850c9e6"></script> </div> </div> <div class="js-zone-container zone-container-responsive"> <div id="dfp-isb" class="everyonelovesstackoverflow everyoneloves__inline-sidebar mx-auto"></div> <div class="js-report-ad-button-container mx-auto" style="width: 300px"></div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader d-flex ai-center mb8"> <div class="flex--item fl1"> <h2 class="mb0" data-answercount="11"> 11 Answers <span style="display:none;" itemprop="answerCount">11</span> </h2> </div> <div class="flex--item"> <div class="d-flex g4 gsx ai-center sm:fd-column sm:ai-start"> <div class="d-flex fd-column ai-end sm:ai-start"> <label class="flex--item fs-caption" for="answer-sort-dropdown-select-menu"> Sorted by: </label> <a class="js-sort-preference-change s-link flex--item fs-fine d-none" data-value="ScoreDesc" href="/questions/11411907/what-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of?answertab=scoredesc#tab-top" > Reset to default </a> </div> <div class="flex--item s-select"> <select id="answer-sort-dropdown-select-menu"> <option value=scoredesc selected=selected > Highest score (default) </option> <option value=trending > Trending (recent votes count more) </option> <option value=modifieddesc > Date modified (newest first) </option> <option value=createdasc > Date created (oldest first) </option> </select> </div> </div> </div> </div> </div> <a name="11412121"></a> <div id="answer-11412121" class="answer js-answer accepted-answer js-accepted-answer" data-answerid="11412121" data-parentid="11411907" data-score="61" data-position-on-page="1" data-highest-scored="1" data-question-has-accepted-highest-score="1" itemprop="acceptedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412121" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412121" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:a2216817e158eb3b,10:1739920671,16:84f78334b86114d7,8:11412121,d9f49d3ae76fe8e9d6564a40bfb5e6601f2909a62908cc9f7476b3a43d6feb1f" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="61"> 61 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:97d7181b2b322310,10:1739920671,16:d419463cfa44e5c4,8:11412121,96c509fff668adfc10f8cf72177f3e0f6537ed424301670019b62ea19511b333" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412121" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412121" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412121/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>I have found cases in real life where both sides of the expression were really cheap, so it shaved off a nanosecond or two to avoid the branch and to use the unconditional <code>&</code> instead of <code>&&</code>. (These were extremely high-performance math utilities, though; I would almost never use this in other code, and I wouldn't have done it anyway without exhaustive benchmarking to prove it was better.)</p> <p>(To give specific examples, <code>x > 0</code> is going to be super cheap and side-effect-free. Why bother risking a branch misprediction to avoid a test that's going to be so cheap anyway? Sure, since it's a <code>boolean</code> the end result is going to be used in a branch anyway, but <code>if (x >= 0 && x <= 10)</code> involves two branches, and <code>if (x >= 0 & x <= 10)</code> involves only one.)</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:15:36"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412121" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412121" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412121/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412121" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:d52e80c50954ac2d,10:1739920671,16:f09d2669d98d3a30,8:11412121,cd974eb1e4c87828ab64226eac509be145be628f7af98510777ba24b5ef7e814" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11412121/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2012-07-10 14:25:53Z' class='relativetime'>Jul 10, 2012 at 14:25</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:15:36Z' class='relativetime'>Jul 10, 2012 at 11:15</span> </div> </div> <div class="user-gravatar32"> <a href="/users/869736/louis-wasserman"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/ae7bb06b9a23a4dd7eea69e853d47d12?s=64&d=identicon&r=PG&f=y&so-version=2" alt="Louis Wasserman's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/869736/louis-wasserman" dir="auto">Louis Wasserman</a><span class="d-none" itemprop="name">Louis Wasserman</span> <div class="-flair"> <span class="reputation-score" title="reputation score 198,171" dir="ltr">198k</span><span title="26 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">26</span></span><span class="v-visible-sr">26 gold badges</span><span title="362 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">362</span></span><span class="v-visible-sr">362 silver badges</span><span title="431 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">431</span></span><span class="v-visible-sr">431 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">12</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412121" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11412121" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="7" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-15049567" class="comment js-comment " data-comment-id="15049567" data-comment-owner-id="869736" data-comment-score="23"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="hot">23</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy"><code>&&</code> involves a branch, when it decides whether or not to evaluate the second condition. Mispredicted branches can be highly expensive on modern CPUs. <code>&</code> avoids that branch.</span> <div class="d-inline-flex ai-center"> – <a href="/users/869736/louis-wasserman" title="198,171 reputation" class="comment-user">Louis Wasserman</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 11:26:01Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 11:26</span> </span> <span title="this comment was edited 1 time"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-15058631" class="comment js-comment " data-comment-id="15058631" data-comment-owner-id="238419" data-comment-score="7"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="warm">7</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">@assylias: See also <a href="http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array">Why is processing a sorted array faster than an unsorted array?</a></span> <div class="d-inline-flex ai-center"> – <a href="/users/238419/blueraja-danny-pflughoeft" title="86,041 reputation" class="comment-user">BlueRaja - Danny Pflughoeft</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 16:22:23Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 16:22</span> </span> </div> </div> </li> <li id="comment-15064569" class="comment js-comment " data-comment-id="15064569" data-comment-owner-id="869736" data-comment-score="25"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="hot">25</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">...Of all my answers to get this many upvotes, I would <i>not</i> have expected it to be this one. Readers, you should almost <i>never</i> use <code>&</code> in actual code -- certainly not without at least an hour's worth of developing microbenchmarks for <i>each</i> place you want to switch a <code>&&</code> to an <code>&</code>. I work on libraries that get used by thousands of programmers, so microoptimizations pay off in those situations, but almost nobody else should do these kinds of things.</span> <div class="d-inline-flex ai-center"> – <a href="/users/869736/louis-wasserman" title="198,171 reputation" class="comment-user">Louis Wasserman</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 20:00:30Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 20:00</span> </span> <span title="this comment was edited 6 times"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> <li id="comment-15095395" class="comment js-comment " data-comment-id="15095395" data-comment-owner-id="216111" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">@LouisWasserman in your example both would be the same as there are no visible side effects, so the compiler would be free to optimize it. The only reason the compiler produces different bytecode is that javac does almost no optimization - the JIT compiler takes care of optimizing the native instructions.</span> <div class="d-inline-flex ai-center"> – <a href="/users/216111/josefx" title="15,656 reputation" class="comment-user">josefx</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-11 20:06:42Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 11, 2012 at 20:06</span> </span> </div> </div> </li> <li id="comment-15124745" class="comment js-comment " data-comment-id="15124745" data-comment-owner-id="144746" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Yep Louis is right. The JIT really isn't capable of optimizing <code>if (val >= 0xcafe && val < 0xdead)</code> sensibly - gcc does though.</span> <div class="d-inline-flex ai-center"> – <a href="/users/144746/voo" title="30,226 reputation" class="comment-user">Voo</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-12 18:50:43Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 12, 2012 at 18:50</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11412121" data-rep=50 data-anon=true> <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button"></a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link " title="Expand to show all comments on this post" href=# onclick="" role="button">Show <b>7</b> more comments</a> </div> </div> </div> </div> <div class="js-zone-container zone-container-main"> <div id="dfp-mlb" class="everyonelovesstackoverflow everyoneloves__mid-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <a name="11412037"></a> <div id="answer-11412037" class="answer js-answer" data-answerid="11412037" data-parentid="11411907" data-score="21" data-position-on-page="2" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412037" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412037" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:21e87ddd0c481f13,10:1739920671,16:3e53f75c415dbbd6,8:11412037,a7a4fe419c856c6bc92ed973689f1cfdaa485541880014d142b6df94fa6a3ce8" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="21"> 21 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:cd59aa5638ff670c,10:1739920671,16:7c4bed11443187b0,8:11412037,be9c65133a054aa4201d7cd4ed639b1376dcf24e562e2971fb1f5ecadc304e04" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412037" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412037" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412037/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>The only difference is that <code>&&</code> and <code>||</code> stop the evaluation as soon as it is known. So for example:</p> <pre><code>if (a != null && a.get() != null) </code></pre> <p>works well with <code>&&</code>, but with <code>&</code> you could get a NullPointerException if a is null.</p> <p>The only case I can think about where you want to use <code>&</code> is if the second operand has a side effect, for example (probably not the best example but you get the point):</p> <pre><code>public static void main(String[] args) { int i = 1; if (i == 0 & ++i != 2) { } System.out.println(i); //2 i = 1; if (i == 0 && ++i != 2) { } System.out.println(i); //1 } </code></pre> <p>However, this looks like smelly code to me (in both cases).</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:10:47"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412037" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412037" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412037/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412037" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:c41b7a65e0d8c364,10:1739920671,16:6faa94cc11423bf7,8:11412037,6aa8787d1b03e35106bb91d644b10fc4d7ee1eb6ffacd6812b8850341f8e0c3a" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11412037/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2012-08-20 09:19:41Z' class='relativetime'>Aug 20, 2012 at 9:19</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:10:47Z' class='relativetime'>Jul 10, 2012 at 11:10</span> </div> </div> <div class="user-gravatar32"> <a href="/users/829571/assylias"><div class="gravatar-wrapper-32"><img src="https://i.sstatic.net/zflGZ.png?s=64" alt="assylias's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/829571/assylias" dir="auto">assylias</a><span class="d-none" itemprop="name">assylias</span> <div class="-flair"> <span class="reputation-score" title="reputation score 328,727" dir="ltr">329k</span><span title="83 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">83</span></span><span class="v-visible-sr">83 gold badges</span><span title="676 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">676</span></span><span class="v-visible-sr">676 silver badges</span><span title="797 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">797</span></span><span class="v-visible-sr">797 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412037" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11412037" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-27122965" class="comment js-comment " data-comment-id="27122965" data-comment-owner-id="113632" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Oh man, that is some smelly code right there. If I found this in some massive class I needed to debug, it would take me <i>hours</i> to spot.</span> <div class="d-inline-flex ai-center"> – <a href="/users/113632/dimo414" title="48,834 reputation" class="comment-user">dimo414</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2013-08-27 02:49:29Z, License: CC BY-SA 3.0' class='relativetime-clean'>Aug 27, 2013 at 2:49</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11412037" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11412053"></a> <div id="answer-11412053" class="answer js-answer" data-answerid="11412053" data-parentid="11411907" data-score="15" data-position-on-page="3" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412053" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412053" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:10a8e4fd3aae1f6a,10:1739920671,16:6a03d8530653ddcd,8:11412053,8b22a753b7877515cc3b28835c33105ffa4c50766e32906fde5df8cc1bb83630" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="15"> 15 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:9a0f2e09f9e66d98,10:1739920671,16:a04a8c205d226dee,8:11412053,c7bf82d5569254b7649725c9d06c9cf1e27e53a1d8c916be602a78237830c93e" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412053" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412053" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412053/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>The && allows the jvm to do short circuit evaluation. That is, if the first argument is false, then it doesn't need to bother checking the second argument.</p> <p>A single & will run both sides regardless.</p> <p>So, as a contrived example, you might have:</p> <pre><code>if (account.isAllowed() & logAccountAndCheckFlag(account)) // Do something </code></pre> <p>In that example, you might always want to log the fact that the owner of the account attempted to do something.</p> <p>I don't think I have ever used a single & in commercial programming though.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:11:53"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412053" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412053" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412053/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412053" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:6e21a6cbbe8e3e29,10:1739920671,16:7e743bc1606d56fd,8:11412053,18bae159eb70f2f207faf863af0d5669325753f70511c3ffac44d61e74440b41" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:11:53Z' class='relativetime'>Jul 10, 2012 at 11:11</span> </div> </div> <div class="user-gravatar32"> <a href="/users/1514554/taskmaster"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/d7ae6392bc8112e2d49e0154e23f9937?s=64&d=identicon&r=PG" alt="Taskmaster's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/1514554/taskmaster" dir="auto">Taskmaster</a><span class="d-none" itemprop="name">Taskmaster</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">1,016</span><span title="11 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">11</span></span><span class="v-visible-sr">11 silver badges</span><span title="17 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">17</span></span><span class="v-visible-sr">17 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412053" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11412053" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11412053" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <div class="js-zone-container zone-container-main"> <div id="dfp-smlb" class="everyonelovesstackoverflow everyoneloves__mid-second-leaderboard everyoneloves__leaderboard"></div> <div class="js-report-ad-button-container " style="width: 728px"></div> </div> <a name="11412295"></a> <div id="answer-11412295" class="answer js-answer" data-answerid="11412295" data-parentid="11411907" data-score="11" data-position-on-page="4" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412295" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412295" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:7f48880fb0bb5e6c,10:1739920671,16:683c29f59c9b08af,8:11412295,a9a7a56839d7ba402dea8df985ae1a1a4119c7f3cad53018a88ee225fe60d661" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="11"> 11 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:13cde212bd4dbf79,10:1739920671,16:f72a010d8b124b70,8:11412295,ee37c2b825230a8ef5d8ea45883db4ec27daa71b31f59b973dbf5f48b2ee9765" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412295" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412295" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412295/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Wikipedia has nicely described the <a href="http://en.wikipedia.org/wiki/Short-circuit_evaluation">Short Circuit Evaluation</a> </p> <p><em>Where do you prefer non short-circuit operators ?</em></p> <p>From the same link:</p> <ul> <li>Untested second condition leads to unperformed side effect </li> <li>Code efficiency</li> </ul> <blockquote> <p>Short-circuiting can lead to errors in branch prediction on modern processors, and dramatically reduce performance (a notable example is highly optimized ray with axis aligned box intersection code in ray tracing)[clarification needed]. Some compilers can detect such cases and emit faster code, but it is not always possible due to possible violations of the C standard. Highly optimized code should use other ways for doing this (like manual usage of assembly code)</p> </blockquote> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:23:34"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412295" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412295" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412295/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412295" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:91f7aea3538cc7b9,10:1739920671,16:c7fb1870de8850bc,8:11412295,b57780401bd537cce046c8b128bf91b4427bde65f09678be2e7e3d1d23d866eb" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:23:34Z' class='relativetime'>Jul 10, 2012 at 11:23</span> </div> </div> <div class="user-gravatar32"> <a href="/users/750040/santosh"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/2d67d6f1d5cafae097a32487d49ef60b?s=64&d=identicon&r=PG" alt="Santosh's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/750040/santosh" dir="auto">Santosh</a><span class="d-none" itemprop="name">Santosh</span> <div class="-flair"> <span class="reputation-score" title="reputation score 17,923" dir="ltr">17.9k</span><span title="4 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">4</span></span><span class="v-visible-sr">4 gold badges</span><span title="57 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">57</span></span><span class="v-visible-sr">57 silver badges</span><span title="79 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">79</span></span><span class="v-visible-sr">79 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">2</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412295" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11412295" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-15075092" class="comment js-comment " data-comment-id="15075092" data-comment-owner-id="613064" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Honestly, the branch prediction issue is hogwash. Any compiler worth its salt will be able to find a branchfree representation even for the short-circuit path, unless the second expression cannot be proven not to have side-effects, which generally involves non-inlineable code. Programmers worrying about the branch predictor before looking at inlining are doing something wrong.</span> <div class="d-inline-flex ai-center"> – <a href="/users/613064/simon-richter" title="29,598 reputation" class="comment-user">Simon Richter</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-11 07:44:12Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 11, 2012 at 7:44</span> </span> </div> </div> </li> <li id="comment-15079131" class="comment js-comment " data-comment-id="15079131" data-comment-owner-id="750040" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">True to a large extent, especially for modern day compilers.</span> <div class="d-inline-flex ai-center"> – <a href="/users/750040/santosh" title="17,923 reputation" class="comment-user">Santosh</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-11 10:23:53Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 11, 2012 at 10:23</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11412295" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11412072"></a> <div id="answer-11412072" class="answer js-answer" data-answerid="11412072" data-parentid="11411907" data-score="7" data-position-on-page="5" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412072" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412072" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:289e1d083b05a846,10:1739920671,16:a42db83f254297d6,8:11412072,63f582a02ea3c8b4b3636bf6c346f34db79168832db46d0d5e025cd0cc6817c6" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="7"> 7 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:c310568eb6f6f40c,10:1739920671,16:264276a81bf01220,8:11412072,dce8972809c8b08700aecfb42945e9e6366c87271f312762b30eb04a5239351c" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412072" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412072" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412072/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If there are side effects that must happen, but that's a little ugly. </p> <p>The bitwise AND (<code>&</code>) is mostly useful for just that - bitwise math.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:13:27"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412072" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412072" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412072/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412072" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:3a6e4881dc0e5c5e,10:1739920671,16:252ad167348482d5,8:11412072,3706dbeeee9ec1959e36ca456cba7042be34b7c536156a7f448235ddbc5726f3" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:13:27Z' class='relativetime'>Jul 10, 2012 at 11:13</span> </div> </div> <div class="user-gravatar32"> <a href="/users/555045/user555045"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/182d0ce855c8324a596648c04643e8f9?s=64&d=identicon&r=PG" alt="user555045's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/555045/user555045" dir="auto">user555045</a><span class="d-none" itemprop="name">user555045</span> <div class="-flair"> <span class="reputation-score" title="reputation score 64,903" dir="ltr">64.9k</span><span title="6 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">6</span></span><span class="v-visible-sr">6 gold badges</span><span title="93 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">93</span></span><span class="v-visible-sr">93 silver badges</span><span title="178 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">178</span></span><span class="v-visible-sr">178 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412072" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11412072" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11412072" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11413925"></a> <div id="answer-11413925" class="answer js-answer" data-answerid="11413925" data-parentid="11411907" data-score="7" data-position-on-page="6" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11413925" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11413925" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:9d514c697d3329e8,10:1739920671,16:433d894cfb324701,8:11413925,4bfa6883e165433899738680e378fd99ce72b1736de3f7066621d4084ccf0bb6" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="7"> 7 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:950394a4c72cd10c,10:1739920671,16:6c32439026f12dce,8:11413925,acc6e31d78d375a3fb9994fc23685264849ab2f3daa8dd14d86e15d9529dedb1" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11413925" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11413925" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11413925/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Input validation is one possible case. You typically want to report all the errors in a form to the user in a single pass instead of stopping after the first one and forcing them to click submit repeatedly and only get a single error each time:</p> <pre><code>public boolean validateField(string userInput, string paramName) { bool valid; //do validation if (valid) { //updates UI to remove error indicator (if present) reportValid(paramName); } else { //updates UI to indicate a problem (color change, error icon, etc) reportInvalid(paramName); } } public boolean validateAllInput(...) { boolean valid = true; valid = valid & validateField(userInput1, paramName1); valid = valid & validateField(userInput2, paramName2); valid = valid & validateField(userInput3, paramName3); valid = valid & validateField(userInput4, paramName4); valid = valid & validateField(userInput5, paramName5); return valid; } public void onSubmit() { if (validateAllInput(...)) { //go to next page of wizard, update database, etc processUserInput(userInput1, userInput2, ... ); } } public void onInput1Changed() { validateField(input1.Text, paramName1); } public void onInput2Changed() { validateField(input2.Text, paramName2); } ... </code></pre> <p>Granted, you could trivially avoid the need for short circuit evaluation in <code>validateAllInput()</code> by refactoring the <code>if (valid) { reportValid() ...</code> logic outside of <code>validateField()</code>; but then you'd need to call the extracted code every time validateField() was called; at a minimum adding 10 extra lines for method calls. As always it's a case of which tradeoff's work best for you.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T13:04:15"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11413925" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11413925" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11413925/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11413925" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:ca9d9af571661805,10:1739920671,16:41edc2aa71be9f70,8:11413925,7c3d1ccef76d7fbd6e120546f16c67e341d04d46f441ac3475d06e6b9a3756de" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11413925/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2012-07-10 17:47:05Z' class='relativetime'>Jul 10, 2012 at 17:47</span></a> </div> </div> <div class="user-gravatar32"> </div> <div class="user-details"> <div class="-flair"> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 13:04:15Z' class='relativetime'>Jul 10, 2012 at 13:04</span> </div> </div> <div class="user-gravatar32"> <a href="/users/85661/dan-is-fiddling-by-firelight"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/3057042cce69c2bf154ee8ca42c74bcc?s=64&d=identicon&r=PG&f=y&so-version=2" alt="Dan Is Fiddling By Firelight's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/85661/dan-is-fiddling-by-firelight" dir="auto">Dan Is Fiddling By Firelight</a><span class="d-none" itemprop="name">Dan Is Fiddling By Firelight</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">6,061</span><span title="18 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">18</span></span><span class="v-visible-sr">18 gold badges</span><span title="79 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">79</span></span><span class="v-visible-sr">79 silver badges</span><span title="131 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">131</span></span><span class="v-visible-sr">131 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">10</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11413925" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11413925" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="5" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-15059567" class="comment js-comment " data-comment-id="15059567" data-comment-owner-id="476716" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">But using <code>&&</code> here is so much better. Otherwise you have to check every parameter pointlessly if the first one isn't valid.</span> <div class="d-inline-flex ai-center"> – <a href="/users/476716/orangedog" title="38,777 reputation" class="comment-user">OrangeDog</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 16:56:20Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 16:56</span> </span> </div> </div> </li> <li id="comment-15059854" class="comment js-comment " data-comment-id="15059854" data-comment-owner-id="10659" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">This is really a subset of the side-effects case listed above but it's a case where side effects might very well be tolerable programming.</span> <div class="d-inline-flex ai-center"> – <a href="/users/10659/loren-pechtel" title="9,093 reputation" class="comment-user">Loren Pechtel</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 17:06:26Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 17:06</span> </span> </div> </div> </li> <li id="comment-15060809" class="comment js-comment " data-comment-id="15060809" data-comment-owner-id="85661" data-comment-score="2"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">2</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">@OrangeDog If I fill out a form with N errors and click submit I'd prefer to be informed that I need to fix X, Y, and Z. It's much more user friendly than: clicking submit, getting an error about X, fixing it, clicking submit again, getting an error about Y....</span> <div class="d-inline-flex ai-center"> – <a href="/users/85661/dan-is-fiddling-by-firelight" title="6,061 reputation" class="comment-user">Dan Is Fiddling By Firelight</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 17:39:07Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 17:39</span> </span> </div> </div> </li> <li id="comment-15060891" class="comment js-comment " data-comment-id="15060891" data-comment-owner-id="85661" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">@LorenPechtel Taskmaster and harold's answers both implied it was something you could do but shouldn't. This is a case where IMO using & and taking advantage of side effects is the better implementation.</span> <div class="d-inline-flex ai-center"> – <a href="/users/85661/dan-is-fiddling-by-firelight" title="6,061 reputation" class="comment-user">Dan Is Fiddling By Firelight</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 17:41:31Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 17:41</span> </span> </div> </div> </li> <li id="comment-15061513" class="comment js-comment " data-comment-id="15061513" data-comment-owner-id="476716" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Oh right, I hadn't spotted you were giving feedback for all of them</span> <div class="d-inline-flex ai-center"> – <a href="/users/476716/orangedog" title="38,777 reputation" class="comment-user">OrangeDog</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-10 18:04:00Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 10, 2012 at 18:04</span> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11413925" data-rep=50 data-anon=true> <a class="js-add-link comments-link dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button"></a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link " title="Expand to show all comments on this post" href=# onclick="" role="button">Show <b>5</b> more comments</a> </div> </div> </div> </div> <a name="11412537"></a> <div id="answer-11412537" class="answer js-answer" data-answerid="11412537" data-parentid="11411907" data-score="6" data-position-on-page="7" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412537" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412537" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:2075ee97063f8b0e,10:1739920671,16:3f16e7c9fde9bd4e,8:11412537,89ca14b7251b0d7d12afaebae4784b151b21e64030f7067e02877b680cbe93fa" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="6"> 6 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:afb19a1b046798de,10:1739920671,16:0f656be2abde4a05,8:11412537,a8816eb2b72ffb6f8326bdaf642ae08fa9013ddb13fea26260e698cb36f53373" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412537" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412537" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412537/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>If the expression are trivial, you may get a micro-optimisation by using <code>&</code> or <code>|</code> in that you are preventing a branch. ie.</p> <pre><code>if(a && b) { } if(!(a || b)) { } </code></pre> <p>is the same as</p> <pre><code>if (a) if (b) { } if (!a) if (!b) { } </code></pre> <p>which has two places a branch can occur. </p> <p>However using an unconditional <code>&</code> or <code>|</code>, there can be only one branch.</p> <p>Whetehr this helps or not is highly dependant on what the code is doing.</p> <p>If you use this, I sugegst commenting it to make it very clear why it has been done.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:39:15"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412537" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412537" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412537/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412537" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:2de993da63dc4598,10:1739920671,16:1a19ae95de1397a0,8:11412537,291861c9cf5514761c4761e3b448350ec156c00638e588c75737fbc42faf2266" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:39:15Z' class='relativetime'>Jul 10, 2012 at 11:39</span> </div> </div> <div class="user-gravatar32"> <a href="/users/57695/peter-lawrey"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/53ee9941b3fefef67175daf212e62d41?s=64&d=identicon&r=PG" alt="Peter Lawrey's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/57695/peter-lawrey" dir="auto">Peter Lawrey</a><span class="d-none" itemprop="name">Peter Lawrey</span> <div class="-flair"> <span class="reputation-score" title="reputation score 533,620" dir="ltr">534k</span><span title="82 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">82</span></span><span class="v-visible-sr">82 gold badges</span><span title="769 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">769</span></span><span class="v-visible-sr">769 silver badges</span><span title="1.2k bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">1.2k</span></span><span class="v-visible-sr">1.2k bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412537" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11412537" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11412537" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11412092"></a> <div id="answer-11412092" class="answer js-answer" data-answerid="11412092" data-parentid="11411907" data-score="5" data-position-on-page="8" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412092" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412092" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:481f8518d9c57bfb,10:1739920671,16:856d1ea873114f8c,8:11412092,a8f1e5f2341f0a305c5f81b57c0e59922987a84fe3d6a6c6d947cfcf2e97609b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="5"> 5 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:83b70ff8652a3bdf,10:1739920671,16:f2370293bec2c886,8:11412092,1f1c31c99a0c137ba9ae64380842000798f043615097817d055776a7afa8ee5f" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412092" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412092" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412092/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>There isn't any specific use of single & but you can consider the following situation.</p> <pre><code>if (x > 0 & someMethod(...)) { // code... } </code></pre> <p>Consider that <code>someMethod()</code> is doing some operation which will modify instance variables or do something which will impact behavior later in processing.</p> <p>So in this case if you use <code>&&</code> operator and the first condition fails it will never go in <code>someMethod()</code>. In this case single <code>&</code> operator will suffice.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:14:11"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412092" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412092" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412092/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412092" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:b9004b9751f7f30a,10:1739920671,16:57c1bf1363b8fbe3,8:11412092,2243ea8fd44ed3de02a49a6cda97b016178d15bd031c68f6b1112b8beb8181c5" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11412092/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2012-07-10 13:03:22Z' class='relativetime'>Jul 10, 2012 at 13:03</span></a> </div> </div> <div class="user-gravatar32"> <a href="/users/4023/matthew-murdoch"><div class="gravatar-wrapper-32"><img src="https://i.sstatic.net/tGVIt.jpg?s=64" alt="Matthew Murdoch's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details"> <a href="/users/4023/matthew-murdoch" dir="auto">Matthew Murdoch</a> <div class="-flair"> <span class="reputation-score" title="reputation score 31,463" dir="ltr">31.5k</span><span title="31 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">31</span></span><span class="v-visible-sr">31 gold badges</span><span title="98 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">98</span></span><span class="v-visible-sr">98 silver badges</span><span title="127 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">127</span></span><span class="v-visible-sr">127 bronze badges</span> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:14:11Z' class='relativetime'>Jul 10, 2012 at 11:14</span> </div> </div> <div class="user-gravatar32"> <a href="/users/1396097/pranav-kevadiya"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/cebe27d4108ad841826578d3b56c6882?s=64&d=identicon&r=PG" alt="Pranav Kevadiya's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/1396097/pranav-kevadiya" dir="auto">Pranav Kevadiya</a><span class="d-none" itemprop="name">Pranav Kevadiya</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">539</span><span title="1 gold badge" aria-hidden="true"><span class="badge1"></span><span class="badgecount">1</span></span><span class="v-visible-sr">1 gold badge</span><span title="6 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">6</span></span><span class="v-visible-sr">6 silver badges</span><span title="18 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">18</span></span><span class="v-visible-sr">18 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412092" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11412092" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11412092" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11424999"></a> <div id="answer-11424999" class="answer js-answer" data-answerid="11424999" data-parentid="11411907" data-score="3" data-position-on-page="9" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11424999" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11424999" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:172089d32243e36f,10:1739920671,16:6de9ffefac49296c,8:11424999,cc2ad2dafd67d3ba5a5c5f4ef586f5dd879e862d95ac169e6d4624460c33a68b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="3"> 3 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:b26920ef7a8b2ceb,10:1739920671,16:86d6fb1d60260029,8:11424999,25adb84faa481a2bd703eae1b1d5735baaef8433928563d5ad8cd93fcea9e6ef" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11424999" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11424999" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11424999/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Because <code>&</code> is a bit-wise operator, you can do up to 32-checks in a single operation concurrently. This can become a significant speed gain for this very specific use cases. If you need to check a large number of conditions, and do it often and the cost of boxing/unboxing the conditions are amortized by the number of checks, or if you store your data on-disk and on-RAM in that format (it is more space efficient to store 32 conditions in a single bitmask), the <code>&</code> operator can give a huge speed benefit over a series of 32 individual <code>&&</code>. For example if you want to select all units that can move, is an infantry, has weapon upgrade, and is controlled by player 3, you can do:</p> <pre><code>int MASK = CAN_MOVE | INFANTRY | CAN_ATTACK | HAS_WEAPON_UPGRADE | PLAYER_3; for (Unit u in allunits) { if (u.mask & MASK == MASK) { ...; } } </code></pre> <p>See <a href="https://stackoverflow.com/questions/7331686/why-and-not/7336620#7336620">my other answers</a> on a related question for more on the topic.</p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-11T03:11:41"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11424999" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11424999" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11424999/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11424999" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:a657b3848ae29685,10:1739920671,16:0916c68bdbf4bc30,8:11424999,58501a5f6097e6e63db4f6bc5d2cc6dca6153a29815eef0123d99e2f61972567" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> <a href="/posts/11424999/revisions" title="show all edits to this post" class="js-gps-track" data-gps-track="post.click({ item: 4, priv: 0, post_type: 2 })">edited <span title='2017-05-23 12:06:14Z' class='relativetime'>May 23, 2017 at 12:06</span></a> </div> </div> <div class="user-gravatar32"> <a href="/users/-1/community"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/a007be5a61f6aa8f3e85ae2fc18dd66e?s=64&d=identicon&r=PG" alt="Community's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details"> <a href="/users/-1/community" dir="auto">Community</a><span class="flex--item s-badge ml2 s-badge__xs mtn2" title="Community Bot — not a real person. Replies to this bot are not monitored.">Bot</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">1</span><span title="1 silver badge" aria-hidden="true"><span class="badge2"></span><span class="badgecount">1</span></span><span class="v-visible-sr">1 silver badge</span> </div> </div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-11 03:11:41Z' class='relativetime'>Jul 11, 2012 at 3:11</span> </div> </div> <div class="user-gravatar32"> <a href="/users/309412/lie-ryan"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/e9739ec5574d9977b522d1c80fb8de84?s=64&d=identicon&r=PG" alt="Lie Ryan's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/309412/lie-ryan" dir="auto">Lie Ryan</a><span class="d-none" itemprop="name">Lie Ryan</span> <div class="-flair"> <span class="reputation-score" title="reputation score 64,875" dir="ltr">64.9k</span><span title="14 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">14</span></span><span class="v-visible-sr">14 gold badges</span><span title="102 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">102</span></span><span class="v-visible-sr">102 silver badges</span><span title="150 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">150</span></span><span class="v-visible-sr">150 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11424999" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11424999" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11424999" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11412097"></a> <div id="answer-11412097" class="answer js-answer" data-answerid="11412097" data-parentid="11411907" data-score="1" data-position-on-page="10" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11412097" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11412097" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:2415bd001ddf24f6,10:1739920671,16:610d6055b3d2b7e8,8:11412097,a8644a24fe6cc30ba0fb88b73886567572fd5e333fbe56f321bceaae1e97320b" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="1"> 1 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:1963ae5b9dc2f6e2,10:1739920671,16:2072d667ce1d6fdc,8:11412097,f213d4578089056986ea57d3b6a9f8fea3363b30083add7436fd45de893acf10" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11412097" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11412097" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11412097/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>The only benefit I can think of is when you need to invoke a method or execute a code, no matter the first expression is evaluated to <code>true</code> or <code>false</code>:</p> <pre><code>public boolean update() { // do whatever you want here return true; } // ... if(x == y & update()){ /* ... */} </code></pre> <p>Although you can do this without <code>&</code>:</p> <pre><code>if(x == y){/* ... */} update(); </code></pre> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-10T11:14:27"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11412097" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11412097" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11412097/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11412097" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:b867a3535f3c55c7,10:1739920671,16:0120004a07579b19,8:11412097,bba6dc379754f4824e5f92dd822f311be1b1c686e6e394567e3e64c372d21377" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info user-hover "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-10 11:14:27Z' class='relativetime'>Jul 10, 2012 at 11:14</span> </div> </div> <div class="user-gravatar32"> <a href="/users/597657/eng-fouad"><div class="gravatar-wrapper-32"><img src="https://i.sstatic.net/0h5ec.jpg?s=64" alt="Eng.Fouad's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/597657/eng-fouad" dir="auto">Eng.Fouad</a><span class="d-none" itemprop="name">Eng.Fouad</span> <div class="-flair"> <span class="reputation-score" title="reputation score 117,607" dir="ltr">118k</span><span title="74 gold badges" aria-hidden="true"><span class="badge1"></span><span class="badgecount">74</span></span><span class="v-visible-sr">74 gold badges</span><span title="324 silver badges" aria-hidden="true"><span class="badge2"></span><span class="badgecount">324</span></span><span class="v-visible-sr">324 silver badges</span><span title="427 bronze badges" aria-hidden="true"><span class="badge3"></span><span class="badgecount">427</span></span><span class="v-visible-sr">427 bronze badges</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount">1</span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11412097" class="comments js-comments-container bt bc-black-200 mt12 " data-post-id="11412097" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-15075563" class="comment js-comment " data-comment-id="15075563" data-comment-owner-id="1968" data-comment-score="1"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-score js-comment-edit-hide"> <span title="number of 'useful comment' votes received" class="cool">1</span> </div> </div> <div class="comment-text js-comment-text-and-form"> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">The first code is quite dangerous. If I saw this in a project I would assume the programmer made an error here, and correct it, thus removing the unconditional side-effect inadvertently.</span> <div class="d-inline-flex ai-center"> – <a href="/users/1968/konrad-rudolph" title="545,766 reputation" class="comment-user">Konrad Rudolph</a> </div> <span class="comment-date" dir="ltr"> <span class="v-visible-sr">Commented</span> <span title='2012-07-11 08:04:06Z, License: CC BY-SA 3.0' class='relativetime-clean'>Jul 11, 2012 at 8:04</span> </span> <span title="this comment was edited 1 time"> <svg aria-hidden="true" class="va-text-bottom o50 svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </span> </div> </div> </li> </ul> </div> <div id="comments-link-11412097" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name="11645553"></a> <div id="answer-11645553" class="answer js-answer" data-answerid="11645553" data-parentid="11411907" data-score="1" data-position-on-page="11" data-highest-scored="0" data-question-has-accepted-highest-score="1" itemprop="suggestedAnswer" itemscope itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container d-flex jc-center fd-column ai-center gs4 fc-black-300" data-post-id="11645553" data-referrer="None"> <button class="js-vote-up-btn flex--item s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" id="upvote-btn-11645553" data-controller="s-tooltip" data-s-tooltip-placement="right" title="This answer is useful" aria-pressed="false" aria-label="Up vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowUp" width="18" height="18" viewBox="0 0 18 18"><path d="M1 12h16L9 4z"/></svg> </button> <input type="hidden" id="voteUpHash" value="70:3:31e,16:65510ee73f81c471,10:1739920671,16:4459ca3e1b500aca,8:11645553,23f41f6d7ce285ced7f342f3e7def53cda5b4a5c46a5165d23453995f744ad70" /> <div class="js-vote-count flex--item d-flex fd-column ai-center fc-theme-body-font fw-bold fs-subheading py4" itemprop="upvoteCount" data-value="1"> 1 </div> <button class="js-vote-down-btn flex--item mb8 s-btn s-btn__muted s-btn__outlined bar-pill bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200" title="This answer is not useful" aria-pressed="false" aria-label="Down vote" data-selected-classes="fc-theme-primary bc-theme-primary bg-theme-primary-100" data-unselected-classes="bc-black-225 f:bc-theme-secondary-400 f:bg-theme-secondary-400 f:fc-black-050 h:bg-theme-primary-200"> <svg aria-hidden="true" class="svg-icon iconArrowDown" width="18" height="18" viewBox="0 0 18 18"><path d="M1 6h16l-8 8z"/></svg> </button> <input type="hidden" id="voteDownHash" value="70:3:31e,16:3e7e913c9b886b1b,10:1739920671,16:948fe6a8269029d4,8:11645553,b9c33de9f43d5853463c28bc67ccb045f72dc3a6cafa6e46a1241db7458bde07" /> <button class="js-saves-btn s-btn s-btn__unset c-pointer py4" type="button" id="saves-btn-11645553" data-controller="s-tooltip" data-s-tooltip-placement="right" data-s-popover-placement="" title="Save this answer." data-is-saved="false" aria-label="Save" data-post-id="11645553" data-post-type-id="2" data-user-privilege-for-post-click="0" aria-controls="" data-s-popover-auto-show="false" > <svg aria-hidden="true" class="fc-theme-primary-400 js-saves-btn-selected d-none svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> <svg aria-hidden="true" class="js-saves-btn-unselected svg-icon iconBookmarkAlt" width="18" height="18" viewBox="0 0 18 18"><path d="m9 10.6 4 2.66V3H5v10.26zM3 17V3c0-1.1.9-2 2-2h8a2 2 0 0 1 2 2v14l-6-4z"/></svg> </button> <div class="js-accepted-answer-indicator flex--item fc-green-400 py6 mtn8 d-none" data-s-tooltip-placement="right" title="Loading when this answer was accepted…" tabindex="0" role="note" aria-label="Accepted"> <div class="ta-center"> <svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8z"/></svg> </div> </div> <a class="js-post-issue flex--item s-btn s-btn__unset c-pointer py6 mx-auto" href="/posts/11645553/timeline" data-shortcut="T" data-ks-title="timeline" data-controller="s-tooltip" data-s-tooltip-placement="right" title="Show activity on this post." aria-label="Timeline"><svg aria-hidden="true" class="mln2 mr0 svg-icon iconHistory" width="19" height="18" viewBox="0 0 19 18"><path d="M3 9a8 8 0 1 1 3.73 6.77L8.2 14.3A6 6 0 1 0 5 9l3.01-.01-4 4-4-4zm7-4h1.01L11 9.36l3.22 2.1-.6.93L10 10z"/></svg></a> </div> </div> <div class="answercell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"> <p>Short-circuiting can lead to errors in branch prediction on modern processors, and dramatically reduce performance (a notable example is highly optimized ray with axis aligned box intersection code in ray tracing)[clarification needed]. </p> </div> <div class="mt24"> <div class="d-flex fw-wrap ai-start jc-end gs8 gsy"> <time itemprop="dateCreated" datetime="2012-07-25T08:24:57"></time> <div class="flex--item mr16" style="flex: 1 1 100px;"> <div class="js-post-menu pt2" data-post-id="11645553" data-post-type-id="2"> <div class="d-flex gs8 s-anchors s-anchors__muted fw-wrap"> <div class="flex--item"> <a href="/a/11645553" rel="nofollow" itemprop="url" class="js-share-link js-gps-track" title="Short permalink to this answer" data-gps-track="post.click({ item: 2, priv: 0, post_type: 2 })" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this answer" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="answer" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="2" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share</a> </div> <div class="flex--item"> <a href="/posts/11645553/edit" class="js-suggest-edit-post js-gps-track" data-gps-track="post.click({ item: 6, priv: 0, post_type: 2 })" title="">Improve this answer</a> </div> <div class="flex--item"> <button type="button" id="btnFollowPost-11645553" class="s-btn s-btn__link js-follow-post js-follow-answer js-gps-track" data-gps-track="post.click({ item: 14, priv: 0, post_type: 2 })" data-controller="s-tooltip " data-s-tooltip-placement="bottom" data-s-popover-placement="bottom" aria-controls="" title="Follow this answer to receive notifications"> Follow <input type="hidden" id="voteFollowHash" value="70:3:31e,16:1b1a4e8c0dc23591,10:1739920671,16:fcf2efcefb145970,8:11645553,91e1c4d9f9d9630dadfb4f3ac4d280b933e76811a90ab2c300e42e693cf2537f" /> </button> </div> </div> <div class="js-menu-popup-container"></div> </div> </div> <div class="post-signature flex--item fl0"> <div class="user-info "> <div class="d-flex "> <div class="user-action-time fl-grow1"> answered <span title='2012-07-25 08:24:57Z' class='relativetime'>Jul 25, 2012 at 8:24</span> </div> </div> <div class="user-gravatar32"> <a href="/users/1550973/anil-patel"><div class="gravatar-wrapper-32"><img src="https://www.gravatar.com/avatar/39fd9bcc1468be9420e47bec415474b2?s=64&d=identicon&r=PG" alt="anil patel's user avatar" width="32" height="32" class="bar-sm"></div></a> </div> <div class="user-details" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/users/1550973/anil-patel" dir="auto">anil patel</a><span class="d-none" itemprop="name">anil patel</span> <div class="-flair"> <span class="reputation-score" title="reputation score " dir="ltr">21</span><span title="1 bronze badge" aria-hidden="true"><span class="badge3"></span><span class="badgecount">1</span></span><span class="v-visible-sr">1 bronze badge</span> </div> </div> </div> </div> </div> </div> </div> <span class="d-none" itemprop="commentCount"></span> <div class="post-layout--right js-post-comments-component"> <div id="comments-11645553" class="comments js-comments-container bt bc-black-200 mt12 dno" data-post-id="11645553" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> </ul> </div> <div id="comments-link-11645553" data-rep=50 data-anon=true> <a class="js-add-link comments-link disabled-link" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”." href="#" role="button">Add a comment</a> <span class="js-link-separator dno"> | </span> <a class="js-show-link comments-link dno" title="Expand to show all comments on this post" href=# onclick="" role="button"></a> </div> </div> </div> </div> <a name='new-answer'></a> <form id="post-form" action="/questions/11411907/answer/submit" method="post" class="js-add-answer-component post-form"> <input type="hidden" id="post-id" value="11411907" /> <input type="hidden" id="qualityBanWarningShown" name="qualityBanWarningShown" value="false" /> <input type="hidden" name="referrer" value="" /> <h2 class="space" id="your-answer-header"> Your Answer </h2> <script> StackExchange.ifUsing("editor", function () { StackExchange.using("externalEditor", function () { StackExchange.using("snippets", function () { StackExchange.snippets.init(); }); }); }, "code-snippets"); </script> <script> StackExchange.ready(function() { var channelOptions = { tags: "".split(" "), id: "1" }; initTagRenderer("".split(" "), "".split(" "), channelOptions); StackExchange.using("externalEditor", function() { // Have to fire editor after snippets, if snippets enabled if (StackExchange.settings.snippets.snippetsEnabled) { StackExchange.using("snippets", function() { createEditor(); }); } else { createEditor(); } }); function createEditor() { StackExchange.prepareEditor({ useStacksEditor: false, heartbeatType: 'answer', autoActivateHeartbeat: false, convertImagesToLinks: true, noModals: true, showLowRepImageUploadWarning: true, reputationToPostImages: 10, bindNavPrevention: true, postfix: "", imageUploadEnabled: false, imageUploader: { brandingHtml: "", contentPolicyHtml: "User contributions licensed under \u003ca href=\"https://stackoverflow.com/help/licensing\"\u003eCC BY-SA\u003c/a\u003e \u003ca href=\"https://stackoverflow.com/legal/acceptable-use-policy\"\u003e(content policy)\u003c/a\u003e", allowUrls: true, }, onDemand: true, discardSelector: ".discard-answer", enableTables: true, isStacksEditorPreviewEnabled: false ,enableTables:true,enableSnippets:true }); } }); </script> <div id="post-editor" class="post-editor js-post-editor d-flex fd-column g4"> <input type="hidden" name="stacksEditorEnabled" value="False" /> <div class="ps-relative"> <div class="wmd-container mb8"> <div id="wmd-button-bar" class="wmd-button-bar btr-sm"></div> <div class="ai-content-policy-notice js-ai-policy-notice fc-black p8 bl br bc-black-300 d-none" aria-hidden="true"> <div class="d-flex jc-space-between ac-center gsx gs2"> <p class="flex--item as-center"><b>Reminder:</b> Answers generated by artificial intelligence tools are not allowed on Stack Overflow. <a href="/help/gen-ai-policy">Learn more</a></p> <button class="flex--item js-dismiss-ai-banner s-btn s-btn__sm s-btn__icon fc-black"><svg aria-hidden="true" class="svg-icon iconClearSm" width="14" height="14" viewBox="0 0 14 14"><path d="M12 3.41 10.59 2 7 5.59 3.41 2 2 3.41 5.59 7 2 10.59 3.41 12 7 8.41 10.59 12 12 10.59 8.41 7z"/></svg></button> </div> </div> <input type="hidden" name="AIPolicyNoticeShown" value="true"/> <div class="js-stacks-validation"> <div class="ps-relative"> <textarea id="wmd-input" name="post-text" class="wmd-input s-input bar0 js-post-body-field" data-editor-type="wmd" data-post-type-id="2" cols="92" rows="15" aria-labelledby="your-answer-header" tabindex="101" data-min-length=""></textarea> </div> <div class="s-input-message mt4 d-none js-stacks-validation-message"></div> </div> </div> </div> <aside class="d-flex ai-start jc-space-between js-answer-help s-notice s-notice__warning pb0 pr4 pt4 mb8 d-none" role="status" aria-hidden="true"> <div class="flex--item pt8"> <p>Thanks for contributing an answer to Stack Overflow!</p><ul><li>Please be sure to <em>answer the question</em>. Provide details and share your research!</li></ul><p>But <em>avoid</em> …</p><ul><li>Asking for help, clarification, or responding to other answers.</li><li>Making statements based on opinion; back them up with references or personal experience.</li></ul><p>To learn more, see our <a href="/help/how-to-answer">tips on writing great answers</a>.</p> </div> <button class="flex--item js-answer-help-close-btn s-btn s-btn__muted fc-black-600"> <svg aria-hidden="true" class="svg-icon iconClear" width="18" height="18" viewBox="0 0 18 18"><path d="M15 4.41 13.59 3 9 7.59 4.41 3 3 4.41 7.59 9 3 13.59 4.41 15 9 10.41 13.59 15 15 13.59 10.41 9z"/></svg> </button> </aside> <div> <div id="draft-saved" class="fc-success h24" style="display:none;">Draft saved</div> <div id="draft-discarded" class="fc-error h24" style="display:none;">Draft discarded</div> </div> <div id="wmd-preview" class="s-prose mb16 wmd-preview js-wmd-preview"></div> <div></div> <div class="edit-block"> <input id="fkey" name="fkey" type="hidden" value="b39cb1a761f93912de068f8e6267ee5702b7d597a570755c5112354b099addd4"> <input id="author" name="author" type="text"> </div> </div> <div class="ps-relative"> <div class="form-item dno new-post-login p0 my16"> <div class="d-flex gs16 md:fd-column new-login-form"> <div class="d-flex fd-column w50 md:w-auto gsy gs8 jc-space-between new-login-left"> <h3 class="flex--item fs-title">Sign up or <a id="login-link" href="/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%23new-answer">log in</a></h3> <script> StackExchange.ready(function () { StackExchange.helpers.onClickDraftSave('#login-link'); }); </script> <div class="flex--item s-btn s-btn__muted s-btn__outlined s-btn__icon google-login" data-ga="["sign up","Sign Up Started - Google","New Post",null,null]"> <svg aria-hidden="true" class="native svg-icon iconGoogle" width="18" height="18" viewBox="0 0 18 18"><path fill="#4285F4" d="M16.51 8H8.98v3h4.3c-.18 1-.74 1.48-1.6 2.04v2.01h2.6a7.8 7.8 0 0 0 2.38-5.88c0-.57-.05-.66-.15-1.18"/><path fill="#34A853" d="M8.98 17c2.16 0 3.97-.72 5.3-1.94l-2.6-2a4.8 4.8 0 0 1-7.18-2.54H1.83v2.07A8 8 0 0 0 8.98 17"/><path fill="#FBBC05" d="M4.5 10.52a4.8 4.8 0 0 1 0-3.04V5.41H1.83a8 8 0 0 0 0 7.18z"/><path fill="#EA4335" d="M8.98 4.18c1.17 0 2.23.4 3.06 1.2l2.3-2.3A8 8 0 0 0 1.83 5.4L4.5 7.49a4.8 4.8 0 0 1 4.48-3.3"/></svg> Sign up using Google </div> <div class="flex--item s-btn s-btn__muted s-btn__outlined s-btn__icon stackexchange-login" data-ga="["sign up","Sign Up Navigation","New Post",null,null]"> <svg aria-hidden="true" class="native svg-icon iconGlyphXSm" width="18" height="18" viewBox="0 0 18 18"><path fill="#BCBBBB" d="M14 16v-5h2v7H2v-7h2v5z"/><path fill="#F48024" d="m12.09.72-1.21.9 4.5 6.07 1.22-.9zM5 15h8v-2H5zm9.15-5.87L8.35 4.3l.96-1.16 5.8 4.83zm-7.7-1.47 6.85 3.19.63-1.37-6.85-3.2zm6.53 5L5.4 11.39l.38-1.67 7.42 1.48z"/></svg> Sign up using Email and Password </div> </div> <input type="hidden" name="use-facebook" class="use-facebook" value="false" /> <input type="hidden" name="use-google" class="use-google" value="false" /> <button type="button" class="d-none js-submit-openid">Submit</button> <div class="d-flex gsy gs8 fd-column w50 md:w-auto new-login-right form-item p0"> <h3 class="flex--item fs-title">Post as a guest</h3> <div class="flex--item"> <div class="d-flex gs4 gsy fd-column"> <label class="s-label" for="display-name">Name</label> <div class="d-flex ps-relative"> <input class="s-input" id="display-name" name="display-name" maxlength="30" type="text" value="" tabindex="105" placeholder="" /> </div> </div> </div> <div class="flex--item"> <div class="d-flex gs4 gsy fd-column"> <div class="flex--item"> <div class="d-flex gs2 gsy fd-column"> <label class="flex--item s-label" for="m-address">Email</label> <p class="flex--item s-description">Required, but never shown</p> </div> </div> <div class="d-flex ps-relative"> <input class="s-input js-post-email-field" id="m-address" name="m-address" type="text" value="" size="40" tabindex="106" placeholder="" /> </div> </div> </div> </div> </div> </div> <script> StackExchange.ready( function () { StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%23new-answer', 'question_page'); } ); </script> <noscript> <h3 class="flex--item fs-title">Post as a guest</h3> <div class="flex--item"> <div class="d-flex gs4 gsy fd-column"> <label class="s-label" for="display-name">Name</label> <div class="d-flex ps-relative"> <input class="s-input" id="display-name" name="display-name" maxlength="30" type="text" value="" tabindex="105" placeholder="" /> </div> </div> </div> <div class="flex--item"> <div class="d-flex gs4 gsy fd-column"> <div class="flex--item"> <div class="d-flex gs2 gsy fd-column"> <label class="flex--item s-label" for="m-address">Email</label> <p class="flex--item s-description">Required, but never shown</p> </div> </div> <div class="d-flex ps-relative"> <input class="s-input js-post-email-field" id="m-address" name="m-address" type="text" value="" size="40" tabindex="106" placeholder="" /> </div> </div> </div> </noscript> </div> <div class="form-submit clear-both d-flex sm:fd-column sm:jc-stretch gs4 ai-center"> <button id="submit-button" class="flex--item fl-shrink0 s-btn s-btn__filled sm:w100" type="submit" tabindex="120" autocomplete="off"> Post Your Answer </button> <button class="flex--item s-btn s-btn__danger fl-shrink0 sm:w100 discard-answer d-none"> Discard </button> <p class="flex--item mb0 fs-italic ml12 sm:ml0"> By clicking “Post Your Answer”, you agree to our <a href='https://stackoverflow.com/legal/terms-of-service/public' name='tos' target='_blank' class='-link'>terms of service</a> and acknowledge you have read our <a href='https://stackoverflow.com/legal/privacy-policy' name='privacy' target='_blank' class='-link'>privacy policy</a>.<input type="hidden" name="legalLinksShown" value="1" /> </p> </div> <div class="js-general-error general-error clear-both d-none" aria-live="polite"></div> </form> <h2 class="bottom-notice" data-loc="1"> <div> Not the answer you're looking for? Browse other questions tagged <ul class='ml0 list-ls-none js-post-tag-list-wrapper d-inline'><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/java" class="s-tag post-tag" title="show questions tagged 'java'" aria-label="show questions tagged 'java'" rel="tag" aria-labelledby="tag-java-tooltip-container" data-tag-menu-origin="Unknown">java</a></li><li class='d-inline mr4 js-post-tag-list-item'><a href="/questions/tagged/optimization" class="s-tag post-tag" title="show questions tagged 'optimization'" aria-label="show questions tagged 'optimization'" rel="tag" aria-labelledby="tag-optimization-tooltip-container" data-tag-menu-origin="Unknown">optimization</a></li></ul> or <a href="/questions/ask">ask your own question</a>. </div> </h2> </div> </div> <div id="sidebar" class="show-votes" role="complementary" aria-label="sidebar"> <div class="s-sidebarwidget s-sidebarwidget__yellow s-anchors s-anchors__grayscale mb16" data-tracker="cb=1"> <ul class="s-sidebarwidget--content s-sidebarwidget__items p0"> <li class="s-sidebarwidget--header"> The Overflow Blog </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://stackoverflow.blog/2025/02/14/solving-the-data-doom-loop/" class="js-gps-track" data-ga="["community bulletin board","The Overflow Blog","https://stackoverflow.blog/2025/02/14/solving-the-data-doom-loop/",null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 0, location: questionpage })">Solving the data doom loop</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <svg aria-hidden="true" class="va-text-top svg-icon iconPencilSm" width="14" height="14" viewBox="0 0 14 14"><path fill="#F1B600" d="m2 10.12 6.37-6.43 1.88 1.88L3.88 12H2z"/><path fill="#E87C87" d="m11.1 1.71 1.13 1.12c.2.2.2.51 0 .71L11.1 4.7 9.21 2.86l1.17-1.15c.2-.2.51-.2.71 0"/></svg> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://stackoverflow.blog/2025/02/18/why-is-it-so-hard-for-companies-to-protect-your-privacy/" class="js-gps-track" data-ga="["community bulletin board","The Overflow Blog","https://stackoverflow.blog/2025/02/18/why-is-it-so-hard-for-companies-to-protect-your-privacy/",null,null]" data-gps-track="communitybulletin.click({ priority: 1, position: 1, location: questionpage })">Why is it so hard for companies to protect your privacy?</a> </div> </li> <li class="s-sidebarwidget--header"> Featured on Meta </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackexchangemeta" title="Meta Stack Exchange"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s" class="js-gps-track" title="Join us for our first community-wide AMA (Ask Me Anything) with Stack Overflow’s CEO (and a few others) on February 26, 2025" data-ga="["community bulletin board","Featured on Meta","https://meta.stackexchange.com/questions/406399/join-us-for-our-first-community-wide-ama-ask-me-anything-with-stack-overflow-s",null,null]" data-gps-track="communitybulletin.click({ priority: 3, position: 2, location: questionpage })">Join us for our first community-wide AMA (Ask Me Anything) with Stack...</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackexchangemeta" title="Meta Stack Exchange"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackexchange.com/questions/406575/bigbird-and-frog-have-joined-us-as-community-managers" class="js-gps-track" data-ga="["community bulletin board","Featured on Meta","https://meta.stackexchange.com/questions/406575/bigbird-and-frog-have-joined-us-as-community-managers",null,null]" data-gps-track="communitybulletin.click({ priority: 3, position: 3, location: questionpage })">bigbird and Frog have joined us as Community Managers</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned" class="js-gps-track" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 4, location: questionpage })">Policy: Generative AI (e.g., ChatGPT) is banned</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak" class="js-gps-track" title="Is it better to redirect users who attempt to perform actions they can't yet take?" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/432989/is-it-better-to-redirect-users-who-attempt-to-perform-actions-they-cant-yet-tak",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 5, location: questionpage })">Is it better to redirect users who attempt to perform actions they can't yet...</a> </div> </li> <li class="s-sidebarwidget--item d-flex px16"> <div class="flex--item1 fl-shrink0"> <div class="favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div> </div> <div class="flex--item wmn0 ow-break-word"> <a href="https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing" class="js-gps-track" data-ga="["community bulletin board","Featured on Meta","https://meta.stackoverflow.com/questions/433034/stacks-editor-development-and-testing",null,null]" data-gps-track="communitybulletin.click({ priority: 6, position: 6, location: questionpage })">Stacks Editor development and testing</a> </div> </li> </ul> </div> <div class="js-zone-container zone-container-sidebar"> <div id="dfp-tsb" class="everyonelovesstackoverflow everyoneloves__top-sidebar"></div> <div class="js-report-ad-button-container " style="width: 300px"></div> </div> <div class="js-zone-container zone-container-sidebar"> <div id="dfp-msb" class="everyonelovesstackoverflow everyoneloves__mid-sidebar"></div> <div class="js-report-ad-button-container " style="width: 300px"></div> </div> <div id="hireme"></div> <div class="s-sidebarwidget mb16 module"> <div class="s-sidebarwidget--header d-flex ai-center pb16"> <a href="https://chat.stackoverflow.com/" class="js-chat-ad-link">Visit chat</a> </div> <div class="s-sidebarwidget--content s-sidebarwidget__items d-none js-chat-ad-rooms"></div> </div> <script> // <!-- StackExchange.ready(function () { var options = { chatUrl: 'https://chat.stackoverflow.com/', reloadUrl: '/api/recent-chat', preloadedData: null, tagBased: true, }; StackExchange.chatAd.init(options); }); // --> </script> <div class="module sidebar-linked"> <h4 id="h-linked">Linked</h4> <div class="linked" data-tracker="lq=1"> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 18273785, position: 0 })"> <a href="/q/18273785" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">5</div> </a> <a href="/questions/18273785/strange-implementation-of-guava-longmath-checkedadd?noredirect=1" class="question-hyperlink">Strange implementation of Guava LongMath.checkedAdd</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 12034965, position: 1 })"> <a href="/q/12034965" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">0</div> </a> <a href="/questions/12034965/what-is-the-difference-between-and-in-java?noredirect=1" class="question-hyperlink">what is the difference between '&' and '&&' in java</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 11227809, position: 2 })"> <a href="/q/11227809" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted extra-large">27416</div> </a> <a href="/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array?noredirect=1" class="question-hyperlink">Why is processing a sorted array faster than processing an unsorted array?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 7331686, position: 3 })"> <a href="/q/7331686" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted large">136</div> </a> <a href="/questions/7331686/why-and-not?noredirect=1" class="question-hyperlink">Why '&&' and not '&'?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 14114179, position: 4 })"> <a href="/q/14114179" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">10</div> </a> <a href="/questions/14114179/why-is-there-a-distinction-between-logical-and-bitwise-operators-in-java-and-c?noredirect=1" class="question-hyperlink">Why is there a distinction between logical and bitwise operators in Java and C#?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 11597978, position: 5 })"> <a href="/q/11597978" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">5</div> </a> <a href="/questions/11597978/are-the-bitwise-operators-or-logical-operators?noredirect=1" class="question-hyperlink">Are the &, |, ^ bitwise operators or logical operators?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 15089890, position: 6 })"> <a href="/q/15089890" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">4</div> </a> <a href="/questions/15089890/do-and-make-any-sense-in-java?noredirect=1" class="question-hyperlink">do | and & make any sense in java?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 13565174, position: 7 })"> <a href="/q/13565174" title="Question score (upvotes - downvotes)"> <div class="answer-votes default">4</div> </a> <a href="/questions/13565174/why-are-there-2-boolean-type-operators-in-java?noredirect=1" class="question-hyperlink">Why are there 2 boolean type operators in Java?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 12141481, position: 8 })"> <a href="/q/12141481" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">0</div> </a> <a href="/questions/12141481/does-it-run-both-arguments-when-using-or-operator?noredirect=1" class="question-hyperlink">Does it run both arguments when using OR operator?</a> </div> <div class="spacer js-gps-track" data-gps-track="linkedquestion.click({ source_post_id: 11411907, target_question_id: 21654109, position: 9 })"> <a href="/q/21654109" title="Question score (upvotes - downvotes)"> <div class="answer-votes answered-accepted default">2</div> </a> <a href="/questions/21654109/while-java-provides-non-short-circuit-version-of-logical-operators-like-logical?noredirect=1" class="question-hyperlink">While java provides non short-circuit version of logical operators (like logical |, &), when are these required?</a> </div> <div class="spacer more ml32 pl16 pt8"> <a href="/questions/linked/11411907">See more linked questions</a> </div> </div> </div> <div class="module sidebar-related"> <h4 id="h-related">Related</h4> <div class="related js-gps-related-questions" data-tracker="rq=3"> <div class="spacer" data-question-id="953957"> <a href="/q/953957" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">2</div> </a> <a href="/questions/953957/what-advantages-are-there-to-using-either-and-or" class="question-hyperlink">What advantages are there to using either AND or &&?</a> </div> <div class="spacer" data-question-id="7814449"> <a href="/q/7814449" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">2</div> </a> <a href="/questions/7814449/vs-how-can-the-first-case-be-used" class="question-hyperlink">& vs && -- how can the first case be used?</a> </div> <div class="spacer" data-question-id="9582429"> <a href="/q/9582429" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">15</div> </a> <a href="/questions/9582429/two-if-statements-vs-one-and-statement" class="question-hyperlink">two IF statements vs. one AND statement</a> </div> <div class="spacer" data-question-id="10945111"> <a href="/q/10945111" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">1</div> </a> <a href="/questions/10945111/significance-of-in-if" class="question-hyperlink">significance of && in if()</a> </div> <div class="spacer" data-question-id="15748269"> <a href="/q/15748269" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">6</div> </a> <a href="/questions/15748269/does-an-else-statement-slow-compile-time-run-speed-in-situations-where-one-cou" class="question-hyperlink">Does an else statement slow compile time/run speed? (In situations where one could be avoided)</a> </div> <div class="spacer" data-question-id="23706260"> <a href="/q/23706260" title="Question score (upvotes - downvotes)" > <div class="answer-votes default">0</div> </a> <a href="/questions/23706260/is-there-a-benefit-to-one-of-these-statements" class="question-hyperlink">Is there a benefit to one of these statements</a> </div> <div class="spacer" data-question-id="47965502"> <a href="/q/47965502" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">8</div> </a> <a href="/questions/47965502/why-was-used-over-in-java-when-comparing-two-bools" class="question-hyperlink">Why was & used over && in java when comparing two bools?</a> </div> <div class="spacer" data-question-id="49243820"> <a href="/q/49243820" title="Question score (upvotes - downvotes)" > <div class="answer-votes default">0</div> </a> <a href="/questions/49243820/when-to-use-or-and-when-to-use-and-in-java" class="question-hyperlink">When to use OR and when to use AND in java</a> </div> <div class="spacer" data-question-id="58275312"> <a href="/q/58275312" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">3</div> </a> <a href="/questions/58275312/is-correct-to-assign-to-a-variable-using-with-the-same-variable-in-java" class="question-hyperlink">Is correct to assign to a variable using && with the same variable in Java?</a> </div> <div class="spacer" data-question-id="67757883"> <a href="/q/67757883" title="Question score (upvotes - downvotes)" > <div class="answer-votes answered-accepted default">1</div> </a> <a href="/questions/67757883/is-there-a-difference-in-ordering-of-conditions-between-the-operator" class="question-hyperlink">Is there a difference in ordering of conditions between the && operator?</a> </div> </div> </div> <script type="text/javascript"> $(function() { $(".js-gps-related-questions .spacer").on("click", function () { fireRelatedEvent($(this).index() + 1, $(this).data('question-id')); }); function fireRelatedEvent(position, questionId) { StackExchange.using("gps", function() { StackExchange.gps.track('related_questions.click', { position: position, originQuestionId: 11411907, relatedQuestionId: +questionId, location: 'sidebar', source: 'Baseline' }); }); } }); </script> <div id="hot-network-questions" class="module tex2jax_ignore"> <h4> <a href="https://stackexchange.com/questions?tab=hot" class="js-gps-track s-link s-link__inherit" data-gps-track="posts_hot_network.click({ item_type:1, location:11 })"> Hot Network Questions </a> </h4> <ul> <li > <div class="favicon favicon-crypto" title="Cryptography Stack Exchange"></div><a href="https://crypto.stackexchange.com/questions/114371/for-block-ciphers-does-a-key-and-input-of-all-zeros-lead-to-a-specific-collisio" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:281 }); posts_hot_network.click({ item_type:2, location:11 })"> For block ciphers, does a key and input of all zeros lead to a specific collision? </a> </li> <li > <div class="favicon favicon-stackoverflow" title="Stack Overflow"></div><a href="https://stackoverflow.com/questions/79446335/how-to-compute-expx-2-when-x-is-large" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:1 }); posts_hot_network.click({ item_type:2, location:11 })"> How to compute `exp(x)/2` when `x` is large? </a> </li> <li > <div class="favicon favicon-superuser" title="Super User"></div><a href="https://superuser.com/questions/1880884/adding-a-context-sensitive-context-menu-entry-for-htm-and-html-files" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:3 }); posts_hot_network.click({ item_type:2, location:11 })"> Adding a context sensitive context menu entry for .htm and .html files </a> </li> <li > <div class="favicon favicon-superuser" title="Super User"></div><a href="https://superuser.com/questions/1880010/how-to-reconstruct-a-lost-veracrypt-keyfile" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:3 }); posts_hot_network.click({ item_type:2, location:11 })"> How to reconstruct a lost VeraCrypt keyfile? </a> </li> <li > <div class="favicon favicon-workplace" title="The Workplace Stack Exchange"></div><a href="https://workplace.stackexchange.com/questions/200331/can-my-organization-see-my-personal-info-on-my-work-computer" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:423 }); posts_hot_network.click({ item_type:2, location:11 })"> can my Organization see my personal info on my work computer </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/737412/missing-endgroup-error-for-flagderiv-package-in-standalone" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })"> Missing \endgroup error for flagderiv package in standalone </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-judaism" title="Mi Yodeya"></div><a href="https://judaism.stackexchange.com/questions/147740/who-said-every-time-you-finish-reading-a-book-ask-yourself-how-are-you-going" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:248 }); posts_hot_network.click({ item_type:2, location:11 })"> Who said: "Every time you finish reading a book, ask yourself how are you going to change?" </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-photo" title="Photography Stack Exchange"></div><a href="https://photo.stackexchange.com/questions/136292/how-does-mirrorless-camera-autofocus-work-with-very-slow-lenses" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:61 }); posts_hot_network.click({ item_type:2, location:11 })"> How does mirrorless camera autofocus work with very "slow" lenses? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-retrocomputing" title="Retrocomputing Stack Exchange"></div><a href="https://retrocomputing.stackexchange.com/questions/31288/did-missing-corrupt-dates-in-cobol-default-to-1875-05-20" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:648 }); posts_hot_network.click({ item_type:2, location:11 })"> Did missing/corrupt dates in COBOL default to 1875-05-20? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-electronics" title="Electrical Engineering Stack Exchange"></div><a href="https://electronics.stackexchange.com/questions/739245/is-it-mathematically-possible-to-solve-for-base-current-in-an-ebers-moll-calcula" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:135 }); posts_hot_network.click({ item_type:2, location:11 })"> Is it mathematically possible to solve for base current in an ebers-moll calculation? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-opensource" title="Open Source Stack Exchange"></div><a href="https://opensource.stackexchange.com/questions/15377/if-a-web-page-s-css-stylesheet-specifies-custom-left-right-margins-that-improv" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:619 }); posts_hot_network.click({ item_type:2, location:11 })"> If a Web page’s CSS stylesheet specifies custom left & right margins that improve its look, does that make a derivative work of the Web browser? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-retrocomputing" title="Retrocomputing Stack Exchange"></div><a href="https://retrocomputing.stackexchange.com/questions/31303/can-someone-identify-the-hardware-in-these-photos" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:648 }); posts_hot_network.click({ item_type:2, location:11 })"> Can someone identify the hardware in these photos? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-security" title="Information Security Stack Exchange"></div><a href="https://security.stackexchange.com/questions/280592/how-can-i-ensure-that-my-git-projects-have-not-been-tampered-with" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:162 }); posts_hot_network.click({ item_type:2, location:11 })"> How can I ensure that my git projects have not been tampered with? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-scifi" title="Science Fiction & Fantasy Stack Exchange"></div><a href="https://scifi.stackexchange.com/questions/294956/what-is-the-origin-of-the-word-literjon" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:186 }); posts_hot_network.click({ item_type:2, location:11 })"> What is the origin of the word "literjon"? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="https://tex.stackexchange.com/questions/737330/how-to-make-all-numbers-in-math-mode-bold" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })"> How to make all numbers in math mode bold? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-music" title="Music: Practice & Theory Stack Exchange"></div><a href="https://music.stackexchange.com/questions/138921/schoenbergs-dynamics-dont-make-sense-how-should-performers-interpret-them" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:240 }); posts_hot_network.click({ item_type:2, location:11 })"> Schoenberg's dynamics don't make sense - how should performers interpret them? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-unix" title="Unix & Linux Stack Exchange"></div><a href="https://unix.stackexchange.com/questions/791209/removing-the-distribution-logo-from-the-gnome-login-screen" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:106 }); posts_hot_network.click({ item_type:2, location:11 })"> Removing the distribution logo from the GNOME login screen </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-physics" title="Physics Stack Exchange"></div><a href="https://physics.stackexchange.com/questions/843042/does-light-of-higher-frequency-higher-energy-appear-to-travel-slower-given-tha" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:151 }); posts_hot_network.click({ item_type:2, location:11 })"> Does light of higher frequency (higher energy) appear to travel slower given that time dilates in the presence of energy? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="https://math.stackexchange.com/questions/5036622/every-real-continuous-function-without-periodic-points-has-an-unbounded-orbit" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })"> Every real continuous function without periodic points has an unbounded orbit </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-quant" title="Quantitative Finance Stack Exchange"></div><a href="https://quant.stackexchange.com/questions/81963/heston-model-lack-of-flexibility" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:204 }); posts_hot_network.click({ item_type:2, location:11 })"> Heston Model lack of flexibility </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-diy" title="Home Improvement Stack Exchange"></div><a href="https://diy.stackexchange.com/questions/314684/how-to-fit-a-4-pipe-through-a-3-space" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:73 }); posts_hot_network.click({ item_type:2, location:11 })"> How to fit a 4" pipe through a 3" space </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-stats" title="Cross Validated"></div><a href="https://stats.stackexchange.com/questions/661528/law-of-total-variance-with-two-conditioning-variables" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:65 }); posts_hot_network.click({ item_type:2, location:11 })"> Law of total variance with two conditioning variables </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-christianity" title="Christianity Stack Exchange"></div><a href="https://christianity.stackexchange.com/questions/105141/why-do-some-christians-use-the-new-testament-but-deny-the-early-church-ecumenica" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:304 }); posts_hot_network.click({ item_type:2, location:11 })"> Why do some Christians use the New Testament but deny the early church ecumenical council doctrines? </a> </li> <li class="dno js-hidden"> <div class="favicon favicon-expatriates" title="Expatriates Stack Exchange"></div><a href="https://expatriates.stackexchange.com/questions/27924/as-a-non-eu-citizen-with-a-french-titre-de-s%c3%a9jour-is-it-possible-to-stay-in-swi" class="js-gps-track question-hyperlink mb0" data-gps-track="site.switch({ item_type:11, target_site:546 }); posts_hot_network.click({ item_type:2, location:11 })"> As a non-EU citizen with a French titre de séjour, is it possible to stay in Switzerland exceeding 90 days? </a> </li> </ul> <a href="#" class="show-more js-show-more js-gps-track" data-gps-track="posts_hot_network.click({ item_type:3, location:11 })"> more hot questions </a> </div> <div id="feed-link" class="js-feed-link"> <a href="/feeds/question/11411907" title="Feed of this question and its answers"> <svg aria-hidden="true" class="fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm0 1.5c6.9 0 12.5 5.6 12.5 12.5H13C13 9.55 8.45 5 3 5zm0 5c4.09 0 7.5 3.41 7.5 7.5H8c0-2.72-2.28-5-5-5zm0 5c1.36 0 2.5 1.14 2.5 2.5H3z"/></svg> Question feed </a> </div> <aside class="s-modal js-feed-link-modal" tabindex="-1" role="dialog" aria-labelledby="feed-modal-title" aria-describedby="feed-modal-description" aria-hidden="true"> <div class="s-modal--dialog js-modal-dialog wmx4" role="document" data-controller="se-draggable"> <h1 class="s-modal--header fw-bold js-first-tabbable" id="feed-modal-title" data-se-draggable-target="handle" tabindex="0"> Subscribe to RSS </h1> <div class="d-flex gs4 gsy fd-column"> <div class="flex--item"> <label class="d-block s-label c-default" for="feed-url"> Question feed <p class="s-description mt2" id="feed-modal-description">To subscribe to this RSS feed, copy and paste this URL into your RSS reader.</p> </label> </div> <div class="d-flex ps-relative"> <input class="s-input" type="text" name="feed-url" id="feed-url" readonly="readonly" value="https://stackoverflow.com/feeds/question/11411907" /> <svg aria-hidden="true" class="s-input-icon fc-orange-400 svg-icon iconRss" width="18" height="18" viewBox="0 0 18 18"><path d="M3 1a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm0 1.5c6.9 0 12.5 5.6 12.5 12.5H13C13 9.55 8.45 5 3 5zm0 5c4.09 0 7.5 3.41 7.5 7.5H8c0-2.72-2.28-5-5-5zm0 5c1.36 0 2.5 1.14 2.5 2.5H3z"/></svg> </div> </div> <a class="s-modal--close s-btn s-btn__muted js-modal-close js-last-tabbable" href="#" aria-label="Close"> <svg aria-hidden="true" class="svg-icon iconClearSm" width="14" height="14" viewBox="0 0 14 14"><path d="M12 3.41 10.59 2 7 5.59 3.41 2 2 3.41 5.59 7 2 10.59 3.41 12 7 8.41 10.59 12 12 10.59 8.41 7z"/></svg> </a> </div> </aside> </div> </div> <script>StackExchange.ready(function(){$.get('/posts/11411907/ivc/cc73?prg=ba14cf23-7599-4fc2-837a-8d432f49d95a');});</script> <noscript><div><img src="/posts/11411907/ivc/cc73?prg=ba14cf23-7599-4fc2-837a-8d432f49d95a" class="dno" alt="" width="0" height="0"></div></noscript><div style="display:none" id="js-codeblock-lang">lang-java</div></div> <script defer src="https://cdn.sstatic.net/Js/questions/show.en.js?v=03feb8d88a8b"></script> <script type="application/json" data-role="module-args" data-module-name="entry-points/questions/show.mod">{"doMarkObsolete":false,"doTimeOnPage":false,"sendAnswerEditorEventsToAEH":true,"sendAnswerEditorEventsToPrizm":true,"questionId":11411907,"sendAuthQuestionVisitToAEH":false,"sendAuthQuestionVisitToPrizm":false}</script> <div id="noscript-wrapper" class="d-none"> <noscript> <img src="/js-false.gif" alt="" /> </noscript> <script type="text/javascript"> const img = document.createElement('img'); img.src = '/js-true.gif'; img.alt = ''; document.getElementById('noscript-wrapper')?.appendChild(img); </script> </div> </div> </div> <script type="text/javascript"> var cam = cam || { opt: {} }; var clcGamLoaderOptions = cam || { opt: {} }; var opt = clcGamLoaderOptions.opt; opt.omni = 'BwoLCLbfyvaPn-g9EAUYw8O4BSACKAI6E3xqYXZhfG9wdGltaXphdGlvbnxIALuUKwjLVzl77BI'; opt.refresh = !1; opt.refreshInterval = 90; opt.sf = !0; opt.hb = !1; opt.ll = !0; opt.tlb_position = 0; opt.personalization_consent = !1; opt.targeting_consent = !1; opt.performance_consent = !1; opt.targeting = {Registered:['false'],Reputation:['new'],'so-tag':['java','optimization'],'tag-reportable':['java','optimization'],NumberOfAnswers:['11'],cf_bot_score:'1'}; opt.adReportEnabled = !0; opt.adReportUrl = '/ads/report-ad'; opt.adReportText = 'Report this ad'; opt.adReportFileTypeErrorMessage = 'Please select a PNG or JPG file.'; opt.adReportFileSizeErrorMessage = 'The file must be under 2 MiB.'; opt.adReportErrorText = 'Error uploading ad report.'; opt.adReportThanksText = 'Thanks for your feedback. We’ll review this against our code of conduct and take action if necessary.'; opt.adReportLoginExpiredMessage = 'Your login session has expired, please login and try again.'; opt.adReportLoginErrorMessage = 'An error occurred when loading the report form - please try again'; opt.adReportModalClass = 'js-ad-report'; opt.countryCode = 'SG'; opt.qualtricsSurveyData = '{"isRegistered":"False","repBucket":"new","referrer":"https%3a%2f%2fstackoverflow.com%2fquestions%2f11411907%2fwhat-are-the-cases-in-which-it-is-better-to-use-unconditional-and-instead-of%2f11412121","accountAge":"0"}'; opt.perRequestGuid = 'ba14cf23-7599-4fc2-837a-8d432f49d95a'; opt.responseHash = '1AG8VfZMRLXPUQP5h2kJp+1amv+GvPnkj/WHuGEsLqk='; opt.targeting.TargetingConsent = ['False_Passive']; opt.allowAccountTargetingForThisRequest = !1; const urlParams = new URLSearchParams(window.location.search); if (urlParams.has('dfptestads')) { const dfptestads = urlParams.get('dfptestads'); opt.targeting.DfpTestAds = dfptestads; } </script> <script>;(()=>{"use strict";var __webpack_modules__={23:(e,t,s)=>{s.d(t,{Z7:()=>c,eq:()=>l,kG:()=>d});const n="248424177",o=(a=location.pathname,/^\/tags\//.test(a)||/^\/questions\/tagged\//.test(a)?"tag-pages":/^\/discussions\//.test(a)||/^\/beta\/discussions/.test(a)?"discussions":/^\/$/.test(a)||/^\/home/.test(a)?"home-page":/^\/jobs$/.test(a)||/^\/jobs\//.test(a)?"jobs":"question-pages");var a;let i=location.hostname;const r={slots:{lb:[[728,90]],mlb:[[728,90]],smlb:[[728,90]],bmlb:[[728,90]],sb:e=>"dfp-tsb"===e?[[300,250],[300,600]]:[[300,250]],"tag-sponsorship":[[730,135]],"mobile-below-question":[[320,50],[300,250]],msb:[[300,250],[300,600]],"talent-conversion-tracking":[[1,1]],"site-sponsorship":[[230,60]]},ids:{"dfp-tlb":"lb","dfp-mlb":"mlb","dfp-smlb":"smlb","dfp-bmlb":"bmlb","dfp-tsb":"sb","dfp-isb":"sb","dfp-tag":"tag-sponsorship","dfp-msb":"msb","dfp-sspon":"site-sponsorship","dfp-m-aq":"mobile-below-question"},idsToExcludeFromAdReports:["dfp-sspon"]};function d(){return Object.keys(r.ids)}function l(e){return r.idsToExcludeFromAdReports.indexOf(e)<0}function c(e,t){var s=e.split("_")[0];const a=r.ids[s];let d=r.slots[a];return"function"==typeof d&&(d=d(s)),{path:`/${n}/${t||i}/${a}/${o}`,sizes:d,zone:a}}},865:(e,t,s)=>{function n(e){return"string"==typeof e?document.getElementById(e):e}function o(e){return!!(e=n(e))&&"none"===getComputedStyle(e).display}function a(e){return!o(e)}function i(e){return!!e}function r(e){return/^\s*$/.test(n(e).innerHTML)}function d(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none"}function l(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.display="none",[].forEach.call(e.children,l)}function c(e){const{style:t}=e;t.height=t.maxHeight=t.minHeight="auto",t.removeProperty("display")}function g(e){const t=document.createElement("script");t.src=e,document.body.appendChild(t)}function p(e){return s=e,(t=[]).push=function(e){return s(),delete this.push,this.push(e)},t;var t,s}function h(e){let t="function"==typeof HTMLTemplateElement;var s=document.createElement(t?"template":"div");return e=e.trim(),s.innerHTML=e,t?s.content.firstChild:s.firstChild}s.d(t,{$Z:()=>c,Bv:()=>h,Gx:()=>g,Nj:()=>n,QZ:()=>p,cf:()=>d,pn:()=>a,wo:()=>l,xb:()=>r,xj:()=>o,yb:()=>i})},763:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{t:()=>AdReports});var _common_helper__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(865),_console__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(276),_ad_units__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(23);class AdReports{constructor(e,t){if(this.googletag=e,this.cam=t,this.allowedFileTypes=["image/png","image/jpg","image/jpeg"],this.ignoreValidation=!1,_console__WEBPACK_IMPORTED_MODULE_1__.cM("Ad reporting init"),this.cam=t,this.callOnButtonClick=e=>this.onButtonClick(e),this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),Array.isArray(t.slotsRenderedEvents)){_console__WEBPACK_IMPORTED_MODULE_1__.cM("Adding report button to "+t.slotsRenderedEvents.length+" events that have transpired");for(var s=0;s<t.slotsRenderedEvents.length;s++)this.handleSlotRendered(t.slotsRenderedEvents[s])}}handleSlotRendered(e){if(e&&e.slot&&!e.isEmpty&&(e.creativeId||e.lineItemId||!e.isEmpty)){var t=e.slot.getSlotElementId();if(t){var s=document.getElementById(t);if(s)if((0,_ad_units__WEBPACK_IMPORTED_MODULE_0__.eq)(t)){var n=s?.closest(".js-zone-container")?.querySelector(".js-report-ad-button-container");n?(n.innerHTML="",n.append(this.createButton(e)),n.style.height="24px",_console__WEBPACK_IMPORTED_MODULE_1__.cM("Added report button to the bottom of "+t)):_console__WEBPACK_IMPORTED_MODULE_1__.cM("Ad report button not found, may be intentional, element: "+t)}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": shouldHaveReportButton = false");else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of "+t+": resolved invalid adUnit element")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid adUnitElementId")}else _console__WEBPACK_IMPORTED_MODULE_1__.cM("Not adding report button to the bottom of element: invalid SlotRenderEndedEvent")}async onButtonClick(e){e.preventDefault();let t=e.target;const s=t.dataset.modalUrl,n=t.dataset.googleEventData;return await this.loadModal(s,t,n),!1}createButton(e){let t=document.createElement("button");var s=JSON.stringify(e);return t.dataset.googleEventData=s,t.dataset.modalUrl=this.cam.opt.adReportUrl,t.dataset.adUnit=e.slot.getSlotElementId(),t.classList.add("js-report-ad","s-btn","s-btn__link","fs-fine","mt2","float-right"),t.append(document.createTextNode(this.cam.opt.adReportText)),t.removeEventListener("click",this.callOnButtonClick),t.addEventListener("click",this.callOnButtonClick),t}async loadModal(url,$link,googleEventData){try{await window.StackExchange.helpers.loadModal(url,{returnElements:window.$($link)}),this.initForm(googleEventData)}catch(e){var message="",response=e.responseText?eval(`(${e.responseText})`):null;message=response&&response.isLoggedOut?this.cam.opt.adReportLoginExpiredMessage:this.cam.opt.adReportLoginErrorMessage,window.StackExchange.helpers.showToast(message,{type:"danger"})}}removeModal(){window.StackExchange.helpers.closePopups(document.querySelectorAll("."+this.cam.opt.adReportModalClass),"dismiss")}initForm(e,t=!1){this.ignoreValidation=t,this.$form=document.querySelector(".js-ad-report-form"),this.$googleEventData=this.$form.querySelector(".js-json-data"),this.$adReportReasons=this.$form.querySelectorAll(".js-ad-report-reason"),this.$adReportReasonOther=this.$form.querySelector(".js-ad-report-reason-other"),this.$fileUploaderInput=this.$form.querySelector(".js-file-uploader-input"),this.$imageUploader=this.$form.querySelector(".js-image-uploader"),this.$clearImageUpload=this.$form.querySelector(".js-clear-image-upload"),this.$imageUploaderText=this.$form.querySelector(".js-image-uploader-text"),this.$imageUploaderPreview=this.$form.querySelector(".js-image-uploader-preview"),this.$fileErrorMessage=this.$form.querySelector(".js-file-error");const s=this.$form.querySelector(".js-drag-drop-enabled"),n=this.$form.querySelector(".js-drag-drop-disabled");this.$googleEventData.value=e,this.$adReportReasons.forEach((e,t)=>e.addEventListener("change",e=>{this.$adReportReasonOther.classList.toggle("d-none","3"!==e.target.value)})),this.$fileUploaderInput.addEventListener("change",()=>{this.validateFileInput()&&this.updateImagePreview(this.$fileUploaderInput.files)}),this.$clearImageUpload.addEventListener("click",e=>{e.preventDefault(),this.clearImageUpload()});try{this.$fileUploaderInput[0].value="",this.$imageUploader.addEventListener("dragenter dragover dragleave drop",this.preventDefaults),this.$imageUploader.addEventListener("dragenter dragover",this.handleDragStart),this.$imageUploader.addEventListener("dragleave drop",this.handleDragEnd),this.$imageUploader.addEventListener("drop",this.handleDrop)}catch(e){s.classList.add("d-none"),n.classList.remove("d-none")}this.$form.removeEventListener("",this.handleDragEnd),this.$form.addEventListener("submit",async e=>(e.preventDefault(),this.submitForm(),!1))}clearImageUpload(){this.$fileUploaderInput.value="",this.$imageUploaderPreview.setAttribute("src",""),this.$imageUploaderPreview.classList.add("d-none"),this.$clearImageUpload.classList.add("d-none"),this.$imageUploaderText.classList.remove("d-none"),this.$imageUploader.classList.add("p16","ba","bas-dashed","bc-black-100")}preventDefaults(e){e.preventDefault(),e.stopPropagation()}handleDragStart(e){this.$imageUploader.classList.remove("bas-dashed"),this.$imageUploader.classList.add("bas-solid","bc-black-100")}handleDragEnd(e){this.$imageUploader.classList.remove("bas-solid","bc-black-100"),this.$imageUploader.classList.add("bas-dashed")}handleDrop(e){var t=e.originalEvent.dataTransfer.files;FileReader&&t&&1===t.length&&(this.$fileUploaderInput.files=t,this.validateFileInput()&&this.updateImagePreview(t))}setError(e){this.$fileErrorMessage.parentElement.classList.toggle("has-error",e)}updateImagePreview(e){this.$imageUploader.classList.remove("p16","ba","bas-dashed","bc-black-100"),this.$clearImageUpload.classList.remove("d-none"),this.$imageUploaderText.classList.add("d-none");var t=new FileReader;t.onload=e=>{null!=e.target&&(this.$imageUploaderPreview.setAttribute("src",e.target.result),this.$imageUploaderPreview.classList.remove("d-none"))},t.readAsDataURL(e[0])}validateFileInput(){if(this.ignoreValidation)return!0;const e=this.cam.opt.adReportFileTypeErrorMessage,t=this.cam.opt.adReportFileSizeErrorMessage;if(null==this.$fileUploaderInput.files)return!1;var s=this.$fileUploaderInput.files[0];return null==s?(this.setError(!0),!1):this.allowedFileTypes.indexOf(s.type)<0?(this.$fileErrorMessage.textContent=e,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):s.size>2097152?(this.$fileErrorMessage.textContent=t,this.$fileErrorMessage.classList.remove("d-none"),this.setError(!0),!1):(this.$fileErrorMessage.classList.add("d-none"),this.setError(!1),!0)}async gatherDiagnosticInfo(){return{BrowserVersion:await this.getBrowserVersion()}}getElementSource(e){return e.outerHTML}getNestedIFrameElement(e){var t=e.querySelector("iframe");return t.contentDocument?t.contentDocument.documentElement:t.contentWindow.document.documentElement}async getBrowserVersion(){return await navigator.userAgentData.getHighEntropyValues(["fullVersionList"]).then(e=>JSON.stringify(e.fullVersionList))}async submitForm(){if(!this.validateFileInput())return!1;this.$form.querySelector("[type=submit]").setAttribute("disabled","true");var e=JSON.parse(this.$googleEventData.value||"{}");e.Reason=parseInt(this.$form.querySelector(".js-ad-report-reason:checked").value,10),e.Description=this.$adReportReasonOther.value,this.$googleEventData.value=JSON.stringify(e);var t=new FormData(this.$form);if("1"===t.get("shareDiagnosticInfo")){var s=await this.gatherDiagnosticInfo();Object.keys(s).forEach(e=>t.append(e,s[e]))}try{const e=await window.fetch(this.$form.getAttribute("action"),{method:this.$form.getAttribute("method"),body:t,cache:"no-cache"}),s=e.headers.get("content-type")||"",o=await e.text();if(!e.ok)throw new Error("response not valid");if(0===s.indexOf("text/html")){var n=(0,_common_helper__WEBPACK_IMPORTED_MODULE_2__.Bv)(o);const e=n?n.querySelector(".js-modal-content"):null;if(_console__WEBPACK_IMPORTED_MODULE_1__.cM("$popupContent"),_console__WEBPACK_IMPORTED_MODULE_1__.cM(e),!e)throw new Error(`Could not find .js-modal-content in response from ${this.$form.getAttribute("action")}`);document.querySelector(".js-modal-content").replaceWith(e)}else window.StackExchange.helpers.showToast(this.cam.opt.adReportThanksText,{type:"success"}),this.removeModal()}catch(e){window.StackExchange.helpers.showToast(this.cam.opt.adReportErrorText,{type:"danger"})}finally{let e=this.$form.querySelector("[type=submit]");e&&e.removeAttribute("disabled")}}}},276:(e,t,s)=>{function n(...e){}function o(...e){}s.d(t,{cM:()=>n,vU:()=>o})}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var s=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](s,s.exports,__webpack_require__),s.exports}__webpack_require__.d=(e,t)=>{for(var s in t)__webpack_require__.o(t,s)&&!__webpack_require__.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var __webpack_exports__={};(()=>{var e=__webpack_require__(276),t=(e=>(e[e.Above=0]="Above",e[e.Below=1]="Below",e))(t||{});const s=Object.assign({},{"lib":"https://clc.stackoverflow.com/Content/bundles/js/gam_loader_script.bundle.741.5deb8dc1a671bfb1646b.js?v=7178a92a336c","style":null,"u":null,"wa":true,"kt":2000,"tto":true,"h":"clc.stackoverflow.com","allowed":"^(((talent\\.)?stackoverflow)|(blog\\.codinghorror)|(.*\\.googlesyndication)|(serverfault|askubuntu|superuser)|([^\\.]+\\.stackexchange))\\.com$","wv":true,"al":false,"abd":true,"cpa_liid":[5882654614],"cpa_cid":[138377597667],"dp":false,"tgt_to":1000,"tgt_u":"https://clc.stackoverflow.com/get-user-acct-tgt","tgt_e":true,"tgt_p":100,"dv_enabled":false,"upo":""});var n=__webpack_require__(23),o=__webpack_require__(865),a=__webpack_require__(763);class i{constructor(t,s){this.googletag=t,this.interval=s,e.cM("Ad refresh init. interval: "+s),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling ad refresh")}onImpressionViewable(t){var s=t.slot;e.cM("ad refresh - slot "+s.getSlotElementId()+" is viewable, initializing refresh"),this.scheduleRefresh(s)}scheduleRefresh(e){setTimeout(()=>this.refreshAdSlot(e),1e3*this.interval)}static refreshMyAd(t,s){let n=t.pubads().getSlots().find(e=>e.getSlotElementId()===s);n&&(e.cM("refreshMyAd - refreshing ad slot "+s),t.pubads().refresh([n]))}static removeMyAd(t,s){let n=t.pubads().getSlots().find(e=>e.getSlotElementId()===s);n&&(e.cM("removeMyAd - destroying ad slot "+s),t.destroySlots([n]))}refreshAdSlot(t){var s=t.getSlotElementId();this.isElementVisibleInBrowser(s)?(e.cM("refreshing ad slot "+s),googletag.pubads().refresh([t])):(e.cM("refresh skipped this time; ad slot not viewable:"+s),this.scheduleRefresh(t))}isElementVisibleInBrowser(e){var t=document.getElementById(e);if(null!==t){var s=t.getBoundingClientRect();if(s.top>=0&&s.left>=0&&s.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&s.right<=(window.innerWidth||document.documentElement.clientWidth))return!0}return!1}}var r=(e=>(e.Off="Off",e.PreSurvey="PreSurvey",e.Collect="Collect",e.PostSurvey="PostSurvey",e))(r||{});class d{constructor(e,t){this.lineItemImpressions=[],this.surveysIdsCompleted=[],this.lineItemImpressions=e,this.surveysIdsCompleted=t}addImpression(e,t){let s={brandId:e,lineItemId:t,timestamp:new Date};this.lineItemImpressions.push(s)}addBrandSurveyCompleted(e){-1===this.surveysIdsCompleted.indexOf(e)&&this.surveysIdsCompleted.push(e)}getTotalBrandImpressions(){let e=new Map;for(let t of this.lineItemImpressions)if(e.has(t.brandId)){let s=e.get(t.brandId);e.set(t.brandId,s+1)}else e.set(t.brandId,1);return e}getBrandLineItemImpressions(e){let t={};for(let s of this.lineItemImpressions)if(s.brandId==e)if(void 0!==t[s.lineItemId]){let e=t[s.lineItemId];t[s.lineItemId]=e+1}else t[s.lineItemId]=1;return t}}class l{constructor(){this.surveyEngagementLocalStorageKey="clc-survey-engagement"}getBrandSurveyEngagement(){let e=localStorage.getItem(this.surveyEngagementLocalStorageKey);if(null===e)return new d([],[]);let t=JSON.parse(e);return new d(t.lineItemImpressions,t.surveysIdsCompleted)}saveBrandSurveyEngagement(e){let t=JSON.stringify(e);localStorage.setItem(this.surveyEngagementLocalStorageKey,t)}}class c{constructor(){this.surveyRepository=new l}getBrandSurveyEngagement(){return this.surveyRepository.getBrandSurveyEngagement()}recordImpression(e,t){let s=this.getBrandSurveyEngagement();s.addImpression(e,t),this.surveyRepository.saveBrandSurveyEngagement(s)}recordBrandSurveyCompleted(e){let t=this.getBrandSurveyEngagement();t.addBrandSurveyCompleted(e),this.surveyRepository.saveBrandSurveyEngagement(t)}}class g{constructor(t,s){this.googletag=t,this.brandSettings=s,this.brandSlotMap=new Map,this.brandSurveyEngagementService=new c,e.cM("Brand Survey init: "+JSON.stringify(s)),void 0!==s?(this.googletag.pubads().addEventListener("slotRenderEnded",e=>this.handleSlotRendered(e)),this.googletag.pubads().addEventListener("impressionViewable",e=>this.onImpressionViewable(e)),e.cM("done enabling Brand Survey")):e.cM("Brand Survey init: brandSettings is undefined, not initializing")}handleSlotRendered(t){e.cM("Brand Survey - slot rendered - slot:"+JSON.stringify(t.slot.getSlotElementId())+" lineItem: "+t.lineItemId);let s=this.findItemWithId(t.lineItemId);if(null===s||s.mode!==r.Collect)this.brandSlotMap.delete(t.slot.getSlotElementId());else{let e={brandId:s.brandId,lineItemId:t.lineItemId};this.brandSlotMap.set(t.slot.getSlotElementId(),e)}}onImpressionViewable(t){let s=t.slot;if(e.cM("ad - Brand Survey - impression viewable. Details: "+JSON.stringify(s.getSlotElementId())),e.cM("ad - Brand Survey - slot "+s.getSlotElementId()+" is viewable"),this.brandSlotMap.has(s.getSlotElementId())){let t=this.brandSlotMap.get(s.getSlotElementId());e.cM("Brand Survey - brand "+t.brandId+" is viewable"),this.recordImpression(this.brandSlotMap.get(s.getSlotElementId()))}}recordImpression(t){e.cM("ad - Brand Survey - recording impression for brand "+t.brandId),this.brandSurveyEngagementService.recordImpression(t.brandId,t.lineItemId)}findItemWithId(t){return e.cM("brand settings: "+JSON.stringify(this.brandSettings)),this.brandSettings.find(e=>e.lineItemIds.includes(t))||null}}const p="response-brand-survey-submit|",h="request-brand-survey-metadata|",m="record-metric-on-server|",u="request-dsp-tags",f="response-dsp-tags|";class _{static refreshAdIfBrandSurveyIsDuplicated(e,t,s){if(this.alreadyCompletedThisBrandSurvey(t)){var n=document.getElementById(s).closest(".js-zone-container");i.removeMyAd(e,s),n&&n.remove()}}static alreadyCompletedThisBrandSurvey(e){return(new c).getBrandSurveyEngagement().surveysIdsCompleted.includes(e)}}window.cam=new class{constructor(t=null){if(this.gptImported=!1,this.slotsRenderedEvents=[],this.collapsed={},e.cM("constructor"),this.clc_options=s,window.clcGamLoaderOptions)Object.assign(this,window.clcGamLoaderOptions);else if(void 0===this.opt){let e=window.opt;e&&(this.opt=e)}}init(){if(e.cM("init"),void 0===this.opt)throw new Error("opt not set, required by GAM Loader");e.cM("init brand survey service"),this.getUserMetaPromise=this.getUserMeta(),e.cM("setup message handler"),window.addEventListener("message",e=>{this.onmessage(e)})}handleSlotRenderedNoAdReport(){if(googletag.pubads().addEventListener("slotRenderEnded",e=>this.applyExtraMarginBottom(e)),Array.isArray(this.slotsRenderedEvents))for(var e=0;e<this.slotsRenderedEvents.length;e++)this.applyExtraMarginBottom(this.slotsRenderedEvents[e])}onmessage(t){let s="omni";if(t.data&&("string"==typeof t.data||t.data instanceof String))if(0===t.data.indexOf("get-omni-")){e.cM("Recevied get-omni message, sending back omni");var n=t.source,a=this.opt.omni,i="string"==typeof a?a:"";n.postMessage([s,i,this.opt.perRequestGuid].join("|"),"*")}else if(0===t.data.indexOf("collapse-")){e.cM("Recevied collapse message, collapse ad iframe"),e.cM(t);for(var r=t.source.window,d=document.getElementsByTagName("IFRAME"),l=0;l<d.length;l++){var g=d[l];if(g.contentWindow==r)return void(0,o.wo)(g.parentElement.parentElement.parentElement)}}else if(0===t.data.indexOf("resize|")){e.cM("Recevied resize message, resize ad iframe"),e.cM(t);let s=this._getFrameByEvent(t),n=t.data.indexOf("|")+1,o=t.data.slice(n),a=parseFloat(o)+.5;e.cM("New iframe height "+a),s.height=a.toString(),s.parentElement.style.height=a.toString()+"px"}else if(0===t.data.indexOf("getmarkup|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied get markup message: "+n);let o=this._getFrameByEvent(t).closest(".everyonelovesstackoverflow");const a=document.createElement("script");a.dataset.adZoneId=o.id,a.src=n,document.body.appendChild(a)}else if(0===t.data.indexOf("window-location|")){let s=t.data.indexOf("|")+1,n=t.data.slice(s);e.cM("Recevied window location message: "+n),n.startsWith("/")||(n="/"+n),window.open(window.location.protocol+"//"+window.location.host+n,"_blank")}else if(0===t.data.indexOf("request-brand-survey-submit|")){let s=t.data.split("|"),n=s[1],o=s[2],a=s[3],i=JSON.parse(a);e.cM(n),e.cM(o),e.cM(a),e.cM("Received brand survey "+n+" response message: "+o);var v=new FormData;for(var b in i)v.append(b,i[b]);let r=this._getFrameByEvent(t);if(_.alreadyCompletedThisBrandSurvey(+n))return e.cM("Already completed this brand survey. Not submitting duplicate to server."),void r.contentWindow.postMessage("response-brand-survey-submit-duplicate|","*");e.cM("Send the brand survey to the server"),fetch(o,{method:"POST",body:v}).then(e=>e.json()).then(e=>r.contentWindow.postMessage({messageType:p},"*")).catch(e=>r.contentWindow.postMessage({messageType:p},"*"))}else if(0===t.data.indexOf("brand-survey-completed-store|")){let s=t.data.split("|"),n=(s[1],s[2]);if(e.cM("Received brand survey completed store message for survey ID "+n),_.alreadyCompletedThisBrandSurvey(+n))return void e.cM("Already completed this brand survey. Not recording duplicate locally.");e.cM("Record brand survey completion locally"),(new c).recordBrandSurveyCompleted(+n)}else if(0===t.data.indexOf(h)){let s=t.data.split("|"),n=s[1],o=s[2];e.cM("Received message: "+h+" with Brand Survey ID "+o);let a=(new c).getBrandSurveyEngagement().getBrandLineItemImpressions(+n),i=JSON.stringify(a),r=this._getFrameByEvent(t);e.cM("sending impression data: "+i),r.contentWindow.postMessage("response-brand-survey-metadata|"+this.opt.responseHash+"|"+this.opt.perRequestGuid+"|"+i+"|"+this.opt.countryCode+"|"+this.opt.qualtricsSurveyData,"*")}else if(0===t.data.indexOf("refresh-if-duplicate-brand-survey|")){let e=t.data.split("|")[1],s=this.getSlotElementIdByEvent(t);_.refreshAdIfBrandSurveyIsDuplicated(googletag,+e,s)}else if(0===t.data.indexOf(m)){e.cM("Received message: "+m+" with args: "+t.data);let s=t.data.split("|"),n=s[1],o=s[2],a=s[3],i=s[4],r=new FormData;r.append("brandSurveyId",a.toString()),r.append("responseHash",this.opt.responseHash),r.append("perRequestGuid",this.opt.perRequestGuid),r.append("questionNumber",n.toString()),r.append("metricType",i.toString()),fetch(o,{method:"POST",body:r}).then(e=>e.ok).catch(t=>{e.cM("SendMetricToServer: Error sending metric to server: "+t)})}else if(0===t.data.indexOf(u)){e.cM("Received message: "+u+" with args: "+t.data);let s=this._getFrameByEvent(t);if(!this.opt.targeting["so-tag"])return void s.contentWindow.postMessage(f,"*");const n=this.opt.targeting["so-tag"].join(",");e.cM("sending targeting tags: "+n),s.contentWindow.postMessage(f+n,"*")}else e.cM("Received unhandled message")}getSlotElementIdByEvent(e){let t=this._getFrameByEvent(e),s=t.parentElement?.parentElement?.id;return s||""}_getFrameByEvent(e){return Array.from(document.getElementsByTagName("iframe")).filter(t=>t.contentWindow===e.source)[0]}classifyZoneIds(e){const t=e.map(o.Nj).filter(o.yb);return{eligible:t.filter(o.xb).filter(o.pn),ineligible:t.filter(o.xj)}}applyExtraMarginBottom(t){if(t&&t.slot&&!t.isEmpty&&(t.creativeId||t.lineItemId||!t.isEmpty)){var s=t.slot.getSlotElementId();if(s){var o=document.getElementById(s);if(o)if((0,n.eq)(s)){var a=o?.closest(".js-zone-container");a.style.marginBottom="24px",e.cM("Applied extra margin to the bottom of "+s)}else e.cM("Not applying extra margin to the bottom of "+s+": shouldHaveReportButton = false");else e.cM("Not applying extra margin to the bottom of "+s+": resolved invalid adUnit element")}else e.cM("Not applying extra margin to the bottom of element: invalid adUnitElementId")}else e.cM("Not applying extra margin to the bottom of element: invalid SlotRenderEndedEvent")}async load(s=(0,n.kG)()){const r=this.opt.tlb_position===t.Above?["dfp-mlb","dfp-smlb"]:["dfp-mlb","dfp-smlb","dfp-tlb"];if(!this.isGptReady())return e.cM("Initializing..."),this.initGpt(),void googletag.cmd.push(()=>this.load(s));this.opt.adReportEnabled?(e.cM("Ad reporting enabled"),this.adReports=new a.t(googletag,this)):(e.cM("Ad reporting not enabled"),this.handleSlotRenderedNoAdReport()),this.opt.refresh?(e.cM("Ad refresh enabled"),this.adRefresh=new i(googletag,this.opt.refreshInterval)):e.cM("Ad refresh not enabled"),this.opt.brandSurveyEnabled&&(e.cM("Brand Survey enabled"),this.brandSurvey=new g(googletag,this.opt.brandSurveySettings)),e.cM("Attempting to load ads into ids: ",s);const{eligible:d,ineligible:l}=this.classifyZoneIds(s);if(this.initDebugPanel(googletag,d.concat(l)),d.forEach(e=>(0,o.cf)(e)),l.forEach(o.wo),0===d.length)return void e.cM("Found no ad ids on page");e.cM("Eligible ids:",d),this.opt.abd&&this.appendAdblockDetector();var c=googletag.pubads().getSlots();if(c){var p=c.filter(e=>s.indexOf(e.getSlotElementId())>=0);googletag.destroySlots(p)}this.opt.sf&&(googletag.pubads().setForceSafeFrame(!0),googletag.pubads().setSafeFrameConfig({allowOverlayExpansion:!0,allowPushExpansion:!0,sandbox:!0})),e.cM("Targeting consent: Checking...");let h=!1,m=!1;void 0!==this.opt.targeting_consent&&(m=!0,e.cM("Targeting consent: Parameter set"),e.cM("Targeting consent: Consent given? ",this.opt.targeting_consent),h=this.opt.targeting_consent),void 0!==this.opt.personalization_consent&&(e.cM("Personalization consent: Parameter set"),e.cM("Personalization consent: Consent given? ",this.opt.personalization_consent),h=h&&this.opt.personalization_consent),h=h&&m,this.setPrivacySettings(h),this.opt.ll||googletag.pubads().enableSingleRequest(),cam.sreEvent||(googletag.pubads().addEventListener("slotRenderEnded",e=>this.onSlotRendered(e)),cam.sreEvent=!0),await this.setTargeting();var u=d.filter(e=>!this.opt.ll||r.indexOf(e.id)<0),f=d.filter(e=>!!this.opt.ll&&r.indexOf(e.id)>=0);e.cM("Up front ids:",u),e.cM("Lazy loaded ids:",f),u.forEach(t=>{e.cM(`Defining ad for element ${t.id}`),this.defineSlot(t.id,googletag),t.setAttribute("data-dfp-zone","true")}),googletag.enableServices(),u.forEach(t=>{e.cM(`Displaying ad for element ${t.id}`),this.clc_options.dv_enabled?window.onDvtagReady(function(){googletag.display(t.id)}):googletag.cmd.push(()=>googletag.display(t.id))}),this.opt.ll&&(e.cM("Enabling lazy loading for GAM"),googletag.pubads().enableLazyLoad({fetchMarginPercent:0,renderMarginPercent:0}),e.cM("Setting up lazy loaded ad units"),f.forEach(t=>{e.cM(`Lazy loading - Defining Slot ${t.id}`),this.defineSlot(t.id,googletag)}),f.forEach(t=>{e.cM(`Lazy loading - Displaying ad for element ${t.id}`),this.clc_options.dv_enabled?window.onDvtagReady(function(){googletag.display(t.id)}):googletag.cmd.push(()=>googletag.display(t.id))}))}setPrivacySettings(e){e||googletag.pubads().setPrivacySettings({nonPersonalizedAds:!0})}async setTargeting(){if(!googletag)throw new Error("googletag not defined");let t=this.opt.targeting;if(!t)throw new Error("Targeting not defined (is "+typeof t+")");Object.keys(t).forEach(s=>{e.cM(`-> targeting - ${s}: ${t[s]}`),googletag.pubads().setTargeting(s,t[s])});let s=!1;if(void 0!==this.opt.targeting_consent&&(s=this.opt.targeting_consent),s){let t=(new c).getBrandSurveyEngagement();if(t.getTotalBrandImpressions().forEach((t,s)=>{e.cM(`-> targeting - BrandImpressions: ${s}: ${t}`),googletag.pubads().setTargeting("brand_"+s.toString()+"_impressions",t.toString())}),t.surveysIdsCompleted.forEach(t=>{e.cM(`-> targeting - SurveysTaken: ${t}`),googletag.pubads().setTargeting("survey_"+t+"_taken","true")}),this.clc_options.tgt_e&&this.getUserMetaPromise){let t=await this.getUserMetaPromise;t&&t.tgt_acct?(e.cM("-> targeting - User Account: "+t.tgt_acct),googletag.pubads().setTargeting("user-acct",t.tgt_acct.company_name),googletag.pubads().setTargeting("user_acct_top",t.tgt_acct.company_name),googletag.pubads().setTargeting("user_industry",t.tgt_acct.industry),googletag.pubads().setTargeting("user_employee_count",t.tgt_acct.employee_range)):e.cM("-> targeting - User Account: Not Found"),t&&Object.prototype.hasOwnProperty.call(t,"is_high_rep_earner")?(e.cM("-> targeting - High Rep Earner: "+t.is_high_rep_earner),googletag.pubads().setTargeting("IsHighRepEarner",t.is_high_rep_earner?"true":"false")):e.cM("-> targeting - High Rep Earner: not found")}if(localStorage){e.cM('Checking local storage for "jobs-last-clicked" key.');let t=localStorage.getItem("jobs-last-clicked")?"true":"false";e.cM(`-> targeting - jobs_clicked: ${t}`),googletag.pubads().setTargeting("jobs_clicked",t)}}}appendAdblockDetector(){const e=document.createElement("div");e.className="adsbox",e.id="clc-abd",e.style.position="absolute",e.style.pointerEvents="none",e.innerHTML=" ",document.body.appendChild(e)}onSlotRendered(s){try{const i=s.slot.getSlotElementId();let r=[];i||r.push("id=0");const d=document.getElementById(i);if(i&&!d&&r.push("el=0"),0!==r.length)return void this.stalled(r.join("&"));const{path:l,sizes:c,zone:g}=(0,n.Z7)(i,this.clc_options.upo);if(this.collapsed[g]&&s.isEmpty)return e.cM(`No line item for the element #${d.id}... collapsing.`),void(0,o.wo)(d);if(this.slotsRenderedEvents.push(s),s.lineItemId||s.creativeId||!s.isEmpty){e.cM(`Rendered ad for element #${d.id} [line item #${s.lineItemId}]`),e.cM(s);var a=d.parentElement;if(a.classList.contains("js-zone-container")){switch((0,o.cf)(a),i){case"dfp-tlb":this.opt.tlb_position===t.Above?a.classList.add("mb8"):a.classList.add("mt16");break;case"dfp-tag":a.classList.add("mb8");break;case"dfp-msb":a.classList.add("mt16");break;case"dfp-mlb":case"dfp-smlb":case"dfp-bmlb":a.classList.add("my8");break;case"dfp-isb":a.classList.add("mt24");break;case"dfp-m-aq":a.classList.add("my12"),a.classList.add("mx-auto")}(0,o.$Z)(a),(0,o.$Z)(d)}else e.cM(`No ad for element #${d.id}, collapsing`),e.cM(s),(0,o.wo)(d)}}catch(t){e.cM("Exception thrown onSlotRendered"),e.cM(t),this.stalled("e=1")}}stalled(e){(new Image).src=`https://${this.clc_options.h}/stalled.gif?${e}`}defineSlot(t,s){"dfp-isb"===t&&(e.cM("-> targeting - Sidebar: Inline"),s.pubads().setTargeting("Sidebar",["Inline"])),"dfp-tsb"===t&&(e.cM("-> targeting - Sidebar: Right"),s.pubads().setTargeting("Sidebar",["Right"]));const{path:o,sizes:a,zone:i}=(0,n.Z7)(t,this.clc_options.upo);e.cM(`Defining slot for ${t}: ${o}, sizes: ${JSON.stringify(a)}`),s.defineSlot(o,a,t).addService(s.pubads())}importGptLibrary(){this.gptImported||(this.gptImported=!0,void 0===this.opt.targeting_consent||this.opt.targeting_consent?(0,o.Gx)("https://securepubads.g.doubleclick.net/tag/js/gpt.js"):(0,o.Gx)("https://pagead2.googlesyndication.com/tag/js/gpt.js"))}importDvLibrary(){this.clc_options.dv_enabled&&(e.cM("Adding DoubleVerify library"),(0,o.Gx)("https://pub.doubleverify.com/dvtag/21569774/DV1289064/pub.js"),e.cM("Adding DoubleVerify onDvtagReady handler"),window.onDvtagReady=function(t,s=750){e.cM("DoubleVerify onDvtagReady called"),window.dvtag=window.dvtag||{},dvtag.cmd=dvtag.cmd||[];const n={callback:t,timeout:s,timestamp:(new Date).getTime()};dvtag.cmd.push(function(){dvtag.queueAdRequest(n)}),setTimeout(function(){const e=n.callback;n.callback=null,e&&e()},s)})}isGptReady(){return"undefined"!=typeof googletag&&!!googletag.apiReady}initGpt(){"undefined"==typeof googletag&&(window.googletag={cmd:(0,o.QZ)(()=>{this.importGptLibrary(),this.importDvLibrary()})})}getUserMeta(){if(this.opt.allowAccountTargetingForThisRequest&&this.clc_options.tgt_e&&this.clc_options.tgt_p>0){if(e.cM("Targeting enabled."),this.clc_options.tgt_p<100){e.cM("Targeting rate limit enabled. Rolling the dice...");const t=Math.floor(100*Math.random())+1;if(e.cM("Rolled "+t+" and the max is "+this.clc_options.tgt_p),t>this.clc_options.tgt_p)return void e.cM("Will not request targeting.")}return e.cM("Will request targeting."),function(e,t,s,n){if(t){const t=new Headers;return t.append("Accept","application/json"),async function(e,t={},s=5e3){if("number"!=typeof s&&null!=s&&!1!==s){if("string"!=typeof s)throw new Error("fetchWithTimeout: timeout must be a number");if(s=parseInt(s),isNaN(s))throw new Error("fetchWithTimeout: timeout must be a number (or string that can be parsed to a number)")}const n=new AbortController,{signal:o}=n,a=fetch(e,{...t,signal:o}),i=setTimeout(()=>n.abort(),s);try{const e=await a;return clearTimeout(i),e}catch(e){throw clearTimeout(i),e}}(s+"?"+new URLSearchParams({omni:e}),{method:"GET",mode:"cors",headers:t},n).then(e=>e.json())}return Promise.reject("No consent")}(this.opt.omni,this.opt.targeting_consent,this.clc_options.tgt_u,this.clc_options.tgt_to).catch(t=>{e.vU("Error fetching user account targeting"),e.vU(t)})}e.cM("Targeting disabled. Will not request account targeting data.")}initDebugPanel(t,s){e.cM("initDebugPanel"),e.cM("Not showing debug panel.")}},window.clcGamLoaderOptions&&(cam.init(),cam.load())})()})();</script> <footer id="footer" class="site-footer js-footer theme-light__forced" role="contentinfo"> <div class="site-footer--container"> <div class="site-footer--logo"> <a href="https://stackoverflow.com" aria-label="Stack Overflow"><svg aria-hidden="true" class="native svg-icon iconGlyphMd" width="32" height="37" viewBox="0 0 32 37"><path fill="#BCBBBB" d="M26 33v-9h4v13H0V24h4v9z"/><path fill="#F48024" d="m21.5 0-2.7 2 9.9 13.3 2.7-2zM26 18.4 13.3 7.8l2.1-2.5 12.7 10.6zM9.1 15.2l15 7 1.4-3-15-7zm14 10.79.68-2.95-16.1-3.35L7 23zM23 30H7v-3h16z"/></svg></a> </div> <nav class="site-footer--nav" aria-label="Footer"> <div class="site-footer--col"> <h5 class="-title"><a href="https://stackoverflow.com" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 15})">Stack Overflow</a></h5> <ul class="-list js-primary-footer-links"> <li><a href="/questions" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 16})">Questions</a></li> <li><a href="/help" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 3 })">Help</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 5 })" href="https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com">Chat</a></li> </ul> </div> <div class="site-footer--col"> <h5 class="-title"><a href="https://stackoverflow.co/" class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 19 })">Products</a></h5> <ul class="-list"> <li><a href="https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams" class="js-gps-track -link" data-ga="["teams traffic","footer - site nav","stackoverflow.com/teams",null,{"dimension4":"teams"}]" data-gps-track="footer.click({ location: 2, link: 29 })">Teams</a></li> <li><a href="https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 21 })">Advertising</a></li> <li><a href="https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent" class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 20 })">Talent</a></li> </ul> </div> <div class="site-footer--col"> <h5 class="-title"><a class="js-gps-track" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">Company</a></h5> <ul class="-list"> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 1 })" href="https://stackoverflow.co/">About</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 27 })" href="https://stackoverflow.co/company/press/">Press</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 9 })" href="https://stackoverflow.co/company/work-here/">Work Here</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 7 })" href="https://stackoverflow.com/legal">Legal</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 8 })" href="https://stackoverflow.com/legal/privacy-policy">Privacy Policy</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 37 })" href="https://stackoverflow.com/legal/terms-of-service/public">Terms of Service</a></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 13 })" href="/contact">Contact Us</a></li> <li id="consent-footer-link"><button type="button" data-controller="cookie-settings" data-action="click->cookie-settings#toggle" class="s-btn s-btn__link py4 js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 38 })" data-consent-popup-loader="footer">Cookie Settings</button></li> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link: 39 })" href="https://stackoverflow.com/legal/cookie-policy">Cookie Policy</a></li> </ul> </div> <div class="site-footer--col site-footer--categories-nav"> <div> <h5 class="-title"><a href="https://stackexchange.com" data-gps-track="footer.click({ location: 2, link: 30 })">Stack Exchange Network</a></h5> <ul class="-list"> <li> <a href="https://stackexchange.com/sites#technology" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Technology </a> </li> <li> <a href="https://stackexchange.com/sites#culturerecreation" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Culture & recreation </a> </li> <li> <a href="https://stackexchange.com/sites#lifearts" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Life & arts </a> </li> <li> <a href="https://stackexchange.com/sites#science" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Science </a> </li> <li> <a href="https://stackexchange.com/sites#professional" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Professional </a> </li> <li> <a href="https://stackexchange.com/sites#business" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Business </a> </li> <li class="mt16 md:mt0"> <a href="https://api.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> API </a> </li> <li> <a href="https://data.stackexchange.com/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 24 })"> Data </a> </li> </ul> </div> </div> </nav> <div class="site-footer--copyright fs-fine md:mt24"> <ul class="-list -social md:mb8"> <li><a class="js-gps-track -link" data-gps-track="footer.click({ location: 2, link:4 })" href="https://stackoverflow.blog?blb=1">Blog</a></li> <li><a href="https://www.facebook.com/officialstackoverflow/" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 31 })">Facebook</a></li> <li><a href="https://twitter.com/stackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 32 })">Twitter</a></li> <li><a href="https://linkedin.com/company/stack-overflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 33 })">LinkedIn</a></li> <li><a href="https://www.instagram.com/thestackoverflow" class="-link js-gps-track" data-gps-track="footer.click({ location: 2, link: 36 })">Instagram</a></li> </ul> <p class="md:mb0"> <span>Site design / logo © 2025 Stack Exchange Inc; </span> <span>user contributions licensed under </span> <a class="-link s-link td-underline" href="https://stackoverflow.com/help/licensing">CC BY-SA</a> <span>. </span> <span id="svnrev">rev 2025.2.18.22736</span> </p> </div> </div> </footer> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-WCZ03SZFCQ"></script> <script> window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } </script> <script> StackExchange.ready(function() { var ga3Settings = { autoLink: ["stackoverflow.blog","info.stackoverflowsolutions.com","stackoverflowsolutions.com"], sendTitles: true, tracker: window.ga, trackingCodes: [ 'UA-108242619-1' ], checkDimension: 'dimension42' }; var customGA4Dimensions = {}; customGA4Dimensions["requestid"] = "ba14cf23-7599-4fc2-837a-8d432f49d95a"; customGA4Dimensions["routename"] = "Questions/Show"; customGA4Dimensions["post_id"] = "11411907"; customGA4Dimensions["tags"] = "|java|optimization|"; var ga4Settings = { tracker: gtag, trackingCodes: [ 'G-WCZ03SZFCQ' ], consentsToPerformanceCookies: "denied", consentsToTargetingCookies: "denied", eventParameters: customGA4Dimensions, checkForAdBlock: true, sendTitles: true, trackClicks: false, }; StackExchange.ga.init({ GA3: ga3Settings, GA4: ga4Settings }); StackExchange.ga.setDimension('dimension2', '|java|optimization|'); StackExchange.ga.setDimension('dimension3', 'Questions/Show'); StackExchange.ga.setDimension('dimension7', "1739920671.2083790402"); StackExchange.ga.trackPageView(); }); </script> <script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js" charset="UTF-8" data-document-language="true" data-domain-script="c3d9f1e3-55f3-4eba-b268-46cee4c6789c"></script> <script defer src="https://cdn.sstatic.net/Js/modules/cookie-consent.en.js?v=36bebc18e04f"></script> <script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'9141bba1de981f6e',t:'MTczOTkyMDY3MS4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script></body> </html>