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 7560359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:52:57+00:00 2026-05-30T12:52:57+00:00

I was wondering if it was possible to do a ternary operation but without

  • 0

I was wondering if it was possible to do a ternary operation but without returning anything.

If it’s not possible in Java is it possible in other languages, if so which ones apply?

name.isChecked() ? name.setChecked(true):name.setChecked(false);
  • 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-30T12:53:00+00:00Added an answer on May 30, 2026 at 12:53 pm

    No, you can’t. But what’s the point of this over an if-else statement? Are you really trying to save 7 characters?

    if (name.isChecked()) {
        name.setChecked(true);
    } else {
        name.setChecked(false);
    }
    

    or if you prefer bad style:

    if (name.isChecked()) name.setChecked(true); else name.setChecked(false);
    

    Never mind the fact that you can just do (in this case):

    name.setChecked(name.isChecked());
    

    The point of the ternary or “conditional” operator is to introduce conditionals into an expression. In other words, this:

    int max = a > b ? a : b;
    

    is meant to be shorthand for this:

    int max;
    if ( a > b ) {
        max = a;
    } else {
        max = b;
    }
    

    If there is no value being produced, the conditional operator is not a shortcut.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have not worked so much with files: I am wondering about possible issues
I was wondering...Is it possible to rebuild the database on Symfony without dropping the
I was wondering...is it possible to use a value from an array which is
I'm wondering if it possible to register assemblies with COM without having to register
Wondering if its possible to communication from javascript to flash without the use of
I was wondering if its possible to embed pseudo-classes inside of each other. I
I was wondering ( if possible ) if there was a program/tool/utility that when
Just toying with the SDK and I was wondering if possible a UITouch event
I'm wondering if its possible to add new class data members at run-time in
I was wondering if its possible to inject a thread into a remote app

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.