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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:26:47+00:00 2026-06-16T00:26:47+00:00

If the following code is possible: Integer a = null; int b = a;

  • 0

If the following code is possible:

Integer a = null;
int b = a;

Does it mean that a function returning a possible null value for an integer is a bad practice?

Edit 1:
There are several different opinions in these answers. I am not enough confident to choose one or another.

  • 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-16T00:26:48+00:00Added an answer on June 16, 2026 at 12:26 am

    That code will give a NullPointerException when you run it. It’s basically equivalent to:

    Integer a = null;
    int b = a.intValue();
    

    … which makes it clearer that it will indeed fail.

    You’re not really assigning a null value to an int – you’re trying and failing.

    It’s fine to use null as a value for an Integer; indeed often Integer is used instead of int precisely as a “nullable equivalent`.

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

Sidebar

Related Questions

Possible Duplicate: What do parentheses surrounding a JavaScript object/function/class declaration mean? Why following code
Is it possible to transform following code to Linq that it will look like
How is it possible that following code even compiles? As far as I can
I have the following code which I use to match fancybox possible elements: $('a.grouped_elements').each(function(){
Possible Duplicate: Is NULL always zero in C? Following code: char *p1 = 0;
The following does not compile: int result = Math.random() + 1; error: possible loss
Possible Duplicate: C programming division in the following code example the result should yield
Suppose I have the following code to collect all the possible combinations. abArray =
In the following code, why is not possible to do this dereferencing: *arr =
Possible Duplicate: Are file descriptors shared when fork()ing? Suppose I have following code in

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.