Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 String \ characters.
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Martin




PostPosted: Sun Sep 26, 2004 12:08 pm   Post subject: String \ characters.

Suppose that I have a function:

public void whatever (String x);

Now, if I had the function called as follows:

code:
whatever ("Hello
World
Here
I come");


What would x look like in this case? I imagine that it would be "Hello\nWorld\nHere\nI come"

Now, my second question, is do these escape characters (\n) cound as characters? What value would x.length return?

And finally, is there any way that I could do something like System.out.println (x) so that it shows all of the escape characters?

Thanks in advance,
Martin
Sponsor
Sponsor
Sponsor
sponsor
Martin




PostPosted: Sun Sep 26, 2004 12:12 pm   Post subject: (No subject)

Alright, I figured it out, except for the display of the escape characters.
wtd




PostPosted: Sun Sep 26, 2004 5:51 pm   Post subject: (No subject)

code:
x.replaceAll("\n", "\\n")
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: