Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Using '\' operator in a string

 
kranthi devarapalem
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

i want to add two strings with '\' parameter between them but it is not working. could someone please help me on this.

Example code:

"Kranthi"+"\"+"Kumar";

this is throwing complier time exception.

Thanks In Advance.

Regards
Kranthi.
 
kranthi devarapalem
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got the answer we have to use "\\" insted of "\". Sorry For wating a post.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
\ is a special character in Java string literals (used for things like "\n"), so you have to escape it, by using \\.

Alternatively, in this case you could use a char literal rather than a String - so '\'.

Edit: ah, you got it yourself. Good .
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!