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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:29:51+00:00 2026-05-31T17:29:51+00:00

I have a bean where I have a field CustAmount which is double, I

  • 0

I have a bean where I have a field “CustAmount “which is double, I tried testing the bean and i dont seem to understand this: When i run on my local machine it gets initialized to 0.0 when instantiated. When i run the same code in my linux test environment it remains null. due to which there is a difference in the retrieved data meaning if i send the CustAmount as null to my Backend i get some data but if i send the CustAmount as 0.0 the query is done on the basis of 0.0 and sends me nothing back.

How is this possible if the code is same, By any chance is it possible that when i do new MyBean() compiled in java 1.5 the double remains null and in 1.6 it gets initialized to 0.0.

I dont know if this is something that happens in two Java versions but thats the only difference on my end.

Thanks for any hint.

Adding code snippet :

public class MyBean {

private double custAmount;

    public void setCustAmount(double custAmount) {
        this.custAmount = custAmount;
    }
public double getCustAmount() {
        return custAmount;
    }

}

And I just do

MyBean mybean =  new MyBean();

its not a Double but a double.
Syed..

  • 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-31T17:29:53+00:00Added an answer on May 31, 2026 at 5:29 pm

    A Java double field will be default initialized to 0.0. A Java Double field will be default initialized to null. These two facts will be true no matter what version of Java you use, and no matter what environment you run it in.


    If you are seeing different behavior in different environments, then the most likely explanation is that you are executing DIFFERENT code in the respective environments (or calling the same code in different ways). Posting some code that exhibits the problem may point to some other problem, but I doubt it.


    Based on your posted code, it is IMPOSSIBLE for custAmount to be null. In the case where you are seeing a null, you must be EITHER using a different version of that code, OR the null must be coming from some other source.

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

Sidebar

Related Questions

I have this bean @XmlRootElement class Test { boolean someValue; List<Field> fields; } I
I have a bean which I map to the database using Hibernate. I'm using
I have a bean of type string[] which has two or more values. I
I have a problem with selectInputDate: I have a backing bean which I am
I am using spring to initialise my beans. I have configured a bean which
I have a method invoking bean which calls a method to perform some sort
I have a MDB (Message driven bean) that receives messages with String which represent
I have a bean with field status . Depending on status value different css
Hard to think of a title for this one! I have a bean that
I have a JPA entity Person which has a @Version long version field. I

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.