Click here to Skip to main content
14,774,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is whitespace a special character in java?<pre>

What I have tried:

I have written a program where the total number of special characters are to be counted
Posted
Updated 28-May-20 8:48am
v2
Comments
ZurdoDev 28-May-20 11:17am
   
It just depends on what you mean by special.

No, a whitespace does not seem to be considered as "special" (if, by that, you mean a character which has to be escaped, or a character which is not a representable glyph).
Using Java Strings to Communicate | Storing Text in Strings | InformIT[^]
How to Remove Special Characters from String in Java - Javatpoint[^]
   
Comments
Member 14846438 28-May-20 11:22am
   
by special i mean as those special characters like parentheses,dollar sign,etc.
Like-$,%,^,&,etc.
phil.o 28-May-20 11:38am
   
I cannot see why $, %, ^, &, etc. would be special; they are all representable glyphs. So is whitespace, even if this glyph actually is blank.
So, what exactly is your definition of special? Do you mean a character which is not a letter nor a digit? A whitespace is not a letter nor a digit, but it is printable.
Member 14846438 28-May-20 12:33pm
   
yes by special i mean to say characters which are neither numbers nor letters.
phil.o 28-May-20 12:41pm
   
In this case, you have to count whitespaces in the function determining how many 'special' characters there are.
Quote:
is whitespace a special character in java?

Yes, white space is special as it separate keywords in a program, and this for about any other programming language too.
No, white space in a string is perfectly legit and have no special meaning.
Quote:
I have written a program where the total number of special characters are to be counted

You forgot to tell if you expect white spaces to be counted or not, and you forgot to tell if result is what you expect or not.
Only your code can tell what is counted as special character or not, but you didn't showed.
   
Comments
Member 14846438 28-May-20 12:42pm
   
the question says to count the total number of special characters entered until the users enters an alphabet.So,in this program should i count whitespace as a special character or not because whitespace is neither a number nor a letter?
Patrice T 28-May-20 13:32pm
   
Use Improve question to update your question.
So that everyone can pay attention to this information.
and show your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900