Difference between revisions of "Special Character"

From Progzoo
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{String Functions}}
 
{{String Functions}}
<question>
+
<question>Some characters must be escaped in string literals:
You can build a string using format. The % values are substituted.
+
Backslash \\
 +
New line  \n
 +
Quote    \"
 +
Tab      \t
 
<shell>
 
<shell>
 
public class P{
 
public class P{
Line 9: Line 12:
 
}}
 
}}
 
</shell>
 
</shell>
<prog>String s = "Tab\tQuote \"New line\n Back-slash\\";
+
<prog>String s = "Tab\tQuote \"New line\n Back-slash\\\\";
 
System.out.println(s);
 
System.out.println(s);
 
</prog>
 
</prog>
 
</question>
 
</question>

Latest revision as of 19:20, 13 January 2008

Some characters must be escaped in string literals:
Backslash \\
New line  \n
Quote     \"
Tab       \t


[Font] [Default] [Show] [Resize] [History] [Profile]