K
Ken Kafieh
does anyone know the ascii code for a tab?
Ken said:does anyone know the ascii code for a tab?
Ken said:does anyone know the ascii code for a tab?
System.out.println("This part goes before the \t, this part after it");
Have you tried looking it up in an ASCII table? You can only find about
a bazillion of them on the web.
Not to mention in the programmer's manuals of many compilers for many
languages.
somewhat verbose when it comes to short programs, a console program thatOr how about the empirical approach: even in Java, which tends to be
Any of those methods would have been quicker than asking on Usenet.
If you need to print a tab:
System.out.println("This part goes before the \t, this part after it");
If you need the actual code: 9
Tony said:Note that you are printing a Unicode character representation, not ASCII.
Equivalent to:
System.out.println('\u0009');
True, but perhaps a bit dangerous.
Chris Smith said:True, but perhaps a bit dangerous. It's sometimes important to know
that \uXXXX is a completely different construct in Java from \t. The
former is translated prior to lexical analysis, and is syntactically
significant; the latter form is interpreted after lexical and syntactic
analysis, and so can never affect the lexical structure or syntax of the
language.
For \t, this rarely matters except for the quibble that \t is only
allowed in a string literal, while \u0009 can occur anywhere in code.
However, try \u000A in a string literal and see what happens... or more
interestingly:
// This looks like \u000A it's all a comment, but it's not!
Now that is good to know,
I never would have thought of it, tnx.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.