Solved

empty string and null difference and similarities in java

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

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
Comment Utility
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 20

Assisted Solution

by:Amitkumar Panchal
Amitkumar Panchal earned 250 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

743 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

15 Experts available now in Live!

Get 1:1 Help Now