Write Code vs. Write Poetry: Print All Ascii
Question: Write a function that prints all ASCII characters. You are not allowed to use for/while loop.
Idea: Recursion. Start from 0, print, add 1 then recursively next until 255
Question: Write a function that prints all ASCII characters. You are not allowed to use for/while loop.
Idea: Recursion. Start from 0, print, add 1 then recursively next until 255
public printAllASIC()
{
printASIC(0);
}
public void printASIC(int charNum)
{
if(charNum<255)
{
char toPrint=(char)charNum;
System.out.println(toPrint);
printASIC(charNum+1);
}
}
Read full article from Write Code vs. Write Poetry: Print All Ascii