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

The Archive Base Latest Questions

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

I recently saw something in some code that made me curious if it was

  • 0

I recently saw something in some code that made me curious if it was actually having some kind of optimization or performance impact. It was a line like this in a constants file:

public static final Object NULL = null;

Then, throughout the code, rather than explicitly using the null keyword, it would be referred to with Constants.NULL.

I’ve seen this kind of thing before with something like:

public static final String EMPTY_STRING = "";

… and that seemed to make at least a little bit of sense, if it’s an attempt to avoid creating lots of duplicate "" instances. But does it really make any difference with null, since it’s not actually any kind of object? Is there something I’m missing?

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

    I don’t think that defining and using NULL in this manner does more than add noise. Perhaps whoever wrote that code came from a C++ background, and preferred the more familiar look of NULL over null.

    The second example is also questionable, since using "" many times would not result in a separate String object created for every use. To quote the JLS:

    Moreover, a string literal always refers to the same instance of class String. This is because string literals – or, more generally, strings that are the values of constant expressions (§15.28) – are “interned” so as to share unique instances, using the method String.intern.

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

Sidebar

Related Questions

I recently saw some code from a college teacher where he had something like
I recently saw something interesting in some c++ code: try { //doStuff } catch
I recently saw some XAML code that looked as follows: <Grid.ColumnDefinitions> <ColumnDefinition Width=2* />
I recently saw someone with a T-shirt with some Perl code on the back.
I came across some code recently that used a custom error handler to turn
Recently I saw some code like this: <tr> <th> Some label: </th> <td> <input
In some code I saw recently there was a structure defined like this: typedef
I recently saw the source code of the Google library Gson and saw something
Saw an interesting piece of code recently, and my mind made a snap judgement
I recently saw a bit of code that looked like this (with sock being

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.