Solved

empty string and null difference and similarities in java

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 42
factorial example 4 39
Capture logon name 13 72
jsp login check 12 30
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…
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.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

776 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