Solved

empty string and null difference and similarities in java

Posted on 2014-11-13
2
339 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 250 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 250 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 learn how to clear a vector as well as how to detect empty vectors in C++.

717 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