The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
November 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Re:Escape Character

Posted by Peter Johansson on October 25, 2001 at 6:47 AM

Hi,

Use the plus(+) sign instead of the backslash

regards,

/Peter

> Hi All!,

> I have a java program (below). I have divided a Long String
> into two lines and use the backslash as an escape character.
> This works fine in C and C++ but seems to be giving a problem
> in java. I consulted my colleagues but none seem to know the
> answer. I hate giving up on problems (ultimately).

> Can somebody help ?

> P.S : I have attached the Compiler Error Message as a comment below the program source.

> Thanks and regards,
> ANJAN. B

>
> /************************************************/
> import java.lang.String;

> public class Test
> {
> public static final void main(String [] args)
> {
> String strTest = "First Line \
> sdfsdfsdf";
> }
> }

> /**
> g:\temp\Test.java:7: Invalid escape character.
> String strTest = "First Line \
> ^
> 1 error
> */

> /************************************************/






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us