Nanda Ardianto Nanda Ardianto - 6 months ago 98
Java Question

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

/*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.

Answer

To check that the character is not within the range of the hexadecimal ASCII codes 48 and 92:

if (root.alpha < 0x48 || root.alpha > 0x92) {
    // ...
}

That is, not within range = less than the start or greater than the end.