Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3428238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:56:06+00:00 2026-05-18T06:56:06+00:00

Which one is better Java coding style? boolean status = true; if (!status) {

  • 0

Which one is better Java coding style?

boolean status = true;
if (!status) {
    //do sth
} else {
    //do sth
}

or:

if (status == false) {
    //do sth
} else {
    //do sth
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:56:07+00:00Added an answer on May 18, 2026 at 6:56 am

    Former, of course. Latter is redundant, and only goes to show that you haven’t understood the concept of booleans very well.

    One more suggestion: Choose a different name for your boolean variable. As per this Java style guide:

    is prefix should be used for boolean variables and methods.

    isSet, isVisible, isFinished,
    isFound, isOpen

    This is the naming convention for
    boolean methods and variables used
    by Sun for the Java core packages.

    Using the is prefix solves a common
    problem of choosing bad boolean names
    like status or flag. isStatus or
    isFlag simply doesn’t fit, and the
    programmer is forced to chose more
    meaningful names.

    Setter methods for boolean variables
    must have set prefix as in:

    void setFound(boolean isFound);

    There are a few alternatives to the
    is prefix that fits better in some
    situations. These are has, can and
    should prefixes:

    boolean hasLicense();
    boolean canEvaluate();
    boolean shouldAbort = false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which one is better when performance is taken into consideration an if else if
Which one performs better to run a game main loop?
Grails vs Rails. Which has better support? And which one is a better choice
Out of the following queries, which method would you consider the better one? What
Which one of the following do you do: var = true; if (...) var
How does The JDK's Logger compare to Apache log4j ? Which one is better
I do not have any experience regarding #D animation. But which one is better
Which one should I use? catch (_com_error e) or catch (_com_error& e)
Which one do you prefer to store text in your database? The original casing
which one of the two is more spread? I want to read out the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.