Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How To Declare and Include Special Characters..

 
John Ray Allen
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone help me how to declare special characters that are frequently used in a program such as ', ", `, (, )...also I want to put those characters inside the System.out.println()..but when I put them inside and enclosed it with quotation mark for example, I want to put the string "), inside the System.out.println()..when I do that I came up with an error..need for your responses..thanks!
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to put some characters into System.out.println() you have to escape them with a \

Example, if you want to print out:
He said, "Hello"

you would have
System.out.println("He said, \"Hello\"");
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use escape characters to print that characters.
You can read all about that at Java Language Specification - Lexical Structure .

Hope this helps and correct me if I am wrong...

thanks
daniel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic