Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many characters in character literal - trying to check if my value is not within ASCII values '\0'

Tags:

java

char

/*Visit only nodes with keys*/
    if(root.alpha != '\0'){

    }

as the title above says. How would I do this better? I'm trying to check if the character (root.alpha) is not within that spectrum. Thanks.

like image 870
Nanda Ardianto Avatar asked Dec 11 '22 16:12

Nanda Ardianto


1 Answers

An unrelated mistake on my part that led me here, but I forgot that ' and " aren't interchangeable in Java like they are in some other languages. ' is for character literals and " is for string literals.

So enclosing any sequence longer than one character in ' will lead to this compile-time error.

like image 102
mz496 Avatar answered Apr 20 '23 01:04

mz496