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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:06:34+00:00 2026-06-02T16:06:34+00:00

Two questions about using a question mark ? and colon : operator within the

  • 0

Two questions about using a question mark “?” and colon “:” operator within the parentheses of a print function: What do they do? Also, does anyone know the standard term for them or where I can find more information on their use? I’ve read that they are similar to an ‘if’ ‘else’ statement.

int row = 10;
int column;
while (row >= 1)
{
    column = 1;
    while(column <= 10)
    {
        System.out.print(row % 2 == 1 ? "<" : "\r>");
        ++column;
    }
    --row;
    System.out.println();
}
  • 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-06-02T16:06:35+00:00Added an answer on June 2, 2026 at 4:06 pm

    This is the ternary conditional operator, which can be used anywhere, not just the print statement. It’s sometimes just called "the ternary operator", but it’s not the only ternary operator, just the most common one.

    Here’s a good example from Wikipedia demonstrating how it works:

    A traditional if-else construct in C, Java and JavaScript is written:

    if (a > b) {
        result = x;
    } else {
        result = y;
    }
    

    This can be rewritten as the following statement:

    result = a > b ? x : y;
    

    Basically it takes the form:

    boolean statement ? true result : false result;
    

    So if the boolean statement is true, you get the first part, and if it’s false you get the second one.

    Try these if that still doesn’t make sense:

    System.out.println(true ? "true!" : "false.");
    System.out.println(false ? "true!" : "false.");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions regarding the following function. Obviously, it is about a chat.
Hi i am using tcpdf in my application and i have two question about
So I have two questions about HashMap s in Java: What is the correct
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
I'm building this website and I have basically two questions about this page: http://sites.publishyours.com.br/silviamecozzi/pt/obra/deserto_das_palmas.php
I have two noobish questions about Flash, Actionscript, Flex etc. 1) With these technologies
So basically, I have two fast questions about kohana urls. 1) With default .htaccess
I've got some questions about two ways to save settings in the web.config. Appsettings
There are two questions to this: How can I best spread the word about
Two quick questions if I may, is this how I should go about taking

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.