This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes character literal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "character literal" Watch "character literal" New topic

character literal

yogi maheshnath
Ranch Hand

Joined: Jan 07, 2008
Posts: 30

How to check if there is any blank charcter in string.

e.g. if(c=='')

its giving compiler error.

Please tell me how to solve it.

Thanks&Regards<br />Yogi MaheshNath
Vishal Matere
Ranch Hand

Joined: Jan 22, 2008
Posts: 81
Assuming that c is String Object, This is how you test if c is empty or not.

SCJP <br />SCWCD <br />SCBCD <br />SCEA-1
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
There is no such thing as a blank character.
A string can be blank, or zero length.
A character is basically a small int, with mapping from numbers to characters.

Java uses unicode, but here's the ASCII table - it's a subset of unicode.

I think you may be interested in the '\0' character, but my psychic powers are weak on Fridays.

Bill Shirley - bshirley -
if (Posts < 30) JavaRanchFAQ);
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41096
Originally posted by Bill Shirley:
I think you may be interested in the '\0' character, but my psychic powers are weak on Fridays.
Difficult to tell; he might want a null character (careful about calling it "blank"; some people call space "blank"), or he might be wondering whether he has whitespace in the String. The examples shown seem to be looking for an empty String however.

Sorry: I didn't notice you are avoiding calling it "blank."
[ May 02, 2008: Message edited by: Campbell Ritchie ]
Consider Paul's rocket mass heater.
subject: character literal