I am trying to make a program that will convert a String
to Binary
. To do that I converted the User Input to char
array. Using for
loops to read the characters in the char
array one by one.
My Problem is how can I read spaces from the char
Array. Here's my code.
for(int i = 0 ; i < UserInput.length() ; i++) {
char c = UserInput.charAt(i);
if (Character.isLetter(c)){
System.out.print ("letter");
}
else if (Character.isDigit(c)){
System.out.print ("number");
}
else if (c== " "){
System.out.print ("space");
}
else
{
System.out.println ("Special Char");
}
}
The Errors shows bad operand types for binary operator '=='else if ((c) == " ")