?
Solved

empty string and null difference and similarities in java

Posted on 2014-11-13
2
Medium Priority
?
352 Views
Last Modified: 2014-11-16
Hi,

I would like to know 'empty string and null difference and similarities in java'.

when to use which one and how with practical example. When we should not use each one. please advise
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1000 total points
ID: 40441241
An empty string is actually a value. It represents a string that consists of no characters. If you were to compare a string to a glass of water, then an empty string would be an empty glass.

null in most every language represents the absence of value. Typically, null is reserved for variables that have yet to be assigned a value, though many people use null as a sentinel value. If you compared null to a glass of water, then null would be like not having a glass at all.
0
 
LVL 21

Assisted Solution

by:Amitkumar Panchal
Amitkumar Panchal earned 1000 total points
ID: 40445990
Agree with kaufmed.

Empty string is a value (ie. ""), where as null is null (nothing). There is no similarities between a null and a value. Same is the case with empty string and a value.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question