• 0

Java: Printing a character from Ascii Code


Question

Hey guys!

I have this program to do for school. It is supposed to analyse a number input by the user and display it byte per byte. Now what I would like to do is get that program to also display the Character contained in a byte... if there is one... so is there a command like

System.out.print (asciicode) ?

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

public static boolean isChar(byte b) {

boolean booResult = (byte)'A' <= b && b <= (byte)'Z' || (byte)'a' <= b && b <= (byte)'z';

return booResult;

}

...

while (isChar(tbytBuffer)) {

System.out.println((char)tbytBuffer[i++]);

}

And that is how I verify the character is a letter and display it... is there any cuter way to verify it is a letter?

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.