Solved

empty string and null difference and similarities in java

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
compre toata in where clue oracle 4 57
rhino JavaScript import, load 25 69
Arrays.asList  VS  ArrayList 4 45
tomcat not starting 6 32
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

862 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now