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

  • Home
  • SEARCH
  • 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 6961051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:28:50+00:00 2026-05-27T15:28:50+00:00

I have two variables that should be compared: Double a = 1D; Double b

  • 0

I have two variables that should be compared:

Double a = 1D;
Double b = 2D;

if (a > b) {
    System.out.print("Ok");
}

In this case java will use autoboxing or compare two object’s references?

  • 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-27T15:28:51+00:00Added an answer on May 27, 2026 at 3:28 pm

    From section 15.20.1 of the JLS:

    The type of each of the operands of a numerical comparison operator must be a type that is convertible (§5.1.8) to a primitive numeric type, or a compile-time error occurs. Binary numeric promotion is performed on the operands (§5.6.2). If the promoted type of the operands is int or long, then signed integer comparison is performed; if this promoted type is float or double, then floating-point comparison is performed.

    Section 5.6.2 starts with:

    When an operator applies binary numeric promotion to a pair of operands, each of which must denote a value that is convertible to a numeric type, the following rules apply, in order, using widening conversion (§5.1.2) to convert operands as necessary:

    • If any of the operands is of a reference type, unboxing conversion (§5.1.8) is performed.

    So yes, unboxing is performed. > has no meaning for references themselves.

    More interesting is the == case where both options would be possible – and in that case, if either operand is a primitive and the other can be converted via numeric promotion, then that happens… but if both are reference types, the reference comparison is performed. For example:

    Double d1 = new Double(1.0);
    Double d2 = new Double(1.0);       
    System.out.println(d1 == d2); // Prints false due to reference comparison
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two string variables which are both file paths. The code that worked
I have two variables that are the result of regex searches. a = re.search('some
I am working with URLLoader and URLRequest in this case. I have two buttons.
I have two variables: X and Y. The value of X will be a
I have a function that should be passed a string with two numbers (as
I have two variables: export portNumber=8888^M export loginIP_BASE=10.1.172.2^M I'm trying to print them both
I have anonymous type variable which i am populating like that(i have two variables
Suppose I have two classes that both contain a static variable, XmlTag. The second
I have two variables, key and value , and I want to add them
I have two variables: char charTime[] = TIME; char buf[] = SOMETHINGELSE; I want

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.