Have a problem in Formatting output with Escape Sequence

class Welcome

{

public static void main(String args[])

{

//Khong the hieu noi

System.out.println("Welcome\tto the world of java");

System.out.println("Happy\tBirthday");

System.out.println("Welcome\" to the world of java");

System.out.println("Bo\ttay");

System.out.println("Be\ttay");

System.out.println("Nhe\ttay");

System.out.println("Welcome\tto Viet Nam");

System.out.println("?Welcome\tto Viet Nam");

System.out.println("!Welcome\tto Viet Nam");

System.out.println("*Welcome\tto Viet Nam");

System.out.println("#Welcome\tto Viet Nam");

System.out.println("$Welcome\tto Viet Nam");

System.out.println("%Welcome\tto Viet Nam");

System.out.println("^Welcome\tto Viet Nam");

System.out.println("&Welcome\tto Viet Nam");

System.out.println("/Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println(" Welcome\tto Viet Nam");

System.out.println(" Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println("Welcome\tto Viet Nam");

System.out.println(" Welcome\tto Viet Nam");

System.out.println("Bodsdsadsme\ttay");

System.out.println("come\tto");

}

}

Let's explain for me...Thanks

[1537 byte] By [bskya] at [2007-10-2 19:49:28]
# 1

Dou you have a question ?

The character and string escape sequences allow for the representation of some nongraphic characters as well as the single quote, double quote, and backslash characters in character literals and string literals:'\b'/* \u0008: backspace*/

'\t'/* \u0009: horizontal tab */

'\n'/* \u000a: linefeed*/

'\f'/* \u000c: form feed*/

'\r'/* \u000d: carriage return */

'\"'/* \u0022: double quote*/

'\''/* \u0027: single quote*/

'\\'/* \u005c: backslash*/

In case you are using Java 1.5, you might be interested in [url=http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintStream.html#printf(java.lang.String, java.lang.Object...)]System.out.printf()[/url], which uses[url=http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax]format string[/url].

TimTheEnchantora at 2007-7-13 22:28:21 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 2
I see. When you run then you will see that I want to ask
bskya at 2007-7-13 22:28:21 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...
# 3

Actually, I don't really see what you want to ask. Sorry.

But in case your problem is about the horizontal tab behaviour:

Note that the horizontal tab character is interpreted by the renderer.

In most case it will skip to the next multiple of 8 chars (like many text editors do.)

For example:System.out.println("Happy\tBirthday");

will certainely output something likeHappyBirthday

|8--|

whileSystem.out.println("Bodsdsadsme\ttay");

will certainely output something likeBodsdsadsmetay

|8--||8--|

just because "Bodsdsadsme" length is more than 8 chars (i.e. more than one tabulation.)

Did you consider using printf ?

TimTheEnchantora at 2007-7-13 22:28:21 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...