Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

character literal

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that c is String Object, This is how you test if c is empty or not.
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 70293
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic