For Programmers: Free Programming Magazines  


Home > Archive > Java Help > February 2007 > printing //////////////\\\\\\\\\\\\\ in JAVA









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author printing //////////////\\\\\\\\\\\\\ in JAVA
Solar^

2007-02-20, 7:07 pm



Hope that someone can help. How does one print these reserved slashes
in Java?
Regards,
R. Stone
Ingo R. Homann

2007-02-20, 7:07 pm

Hi,

Solar^ wrote:
> Hope that someone can help. How does one print these reserved slashes
> in Java?
> Regards,
> R. Stone


Special chars like ', " and \ must be quoted in Java (sometimes (*)).
The quoting char is itself \.

So, to represent one \ you must use \\:

System.out.println("\\");
System.out.println('\');

See also:

System.out.println("\"");
System.out.println(''');
System.out.println("\n");
System.out.println('\n');
System.out.println("\t");
System.out.println('\t');

(*) But:

System.out.println("'");
System.out.println('"');

Hth,
Ingo

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com