This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How To Declare and Include Special Characters.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How To Declare and Include Special Characters.." Watch "How To Declare and Include Special Characters.." New topic

How To Declare and Include Special Characters..

John Ray Allen
Ranch Hand

Joined: Jan 06, 2005
Posts: 50
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

Joined: Dec 29, 2004
Posts: 1071
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

Joined: Sep 14, 2001
Posts: 582
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...

Don't get me started about those stupid light bulbs.
subject: How To Declare and Include Special Characters..
It's not a secret anymore!