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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:05:26+00:00 2026-05-24T08:05:26+00:00

Below is a fairly standard piece of Java code which has been translated to

  • 0

Below is a fairly standard piece of Java code which has been translated to Scala

 val result: ResultSet = statement.executeQuery(query)

  while (result.next) {
    if (result.getDouble("FIELD") != null) {

    }
 }

Why do I get

warning: comparing values of types Double and Null using `!=’ will
always yield true?

  • 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-24T08:05:28+00:00Added an answer on May 24, 2026 at 8:05 am

    If I understand correctly, it’s because a Double in scala can never be Null.

    Trying something simple out in the console came up with errors:

    scala> val d:Double = null
    <console>:13: error: type mismatch;
    found   : Null(null)
    required: Double
    

    On the other hand, a java.lang.Double can be null:

    scala> val d:java.lang.Double = null
    d: java.lang.Double = null
    

    So your double is probably a Scala Double as opposed to a Java Double

    EDIT I poked around a bit, and it looks like using java.sql.ResultSet’s getDouble method will return a scala Double object, which accounts for the warning. As for an alternative to checking for null, I’m not sure that was ever an option. In Java, the method returned a primitive double, which would default to 0.0. I may be wrong, but I don’t think Java primitives could ever be null.

    Edit2 Removed some stuff that was more speculation than answer.

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

Sidebar

Related Questions

I'm fairly new to ggplot. I have made a bumpplot using code posted below.
I have fairly decent C++ skills, but this one cast has been giving me
Below is part of the XML which I am processing with PHP's XSLTProcessor :
Below is the code of a simple html with a table layout. In FF
Below I have the code that allows me to edit a table row inline.
I have a fairly standard layout for the first screen of the setup wizard
It's fairly simple to convert a double to a hexadecimal string in Java. But
I have this formula in a function below. It's a fairly simple concept, yet
Below is the code for my PHP contact form. But when I submit it
I have a fairly simple application which downloads files in a thread. This thread

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.