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.