File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to print in Double quotes ? 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 print in Double quotes ?" Watch "How to print in Double quotes ?" New topic
Author

How to print in Double quotes ?

Neha Mohit
Ranch Hand

Joined: Apr 25, 2006
Posts: 87
hi ,

How do we print in double quotes in java

for eg.

class Demo
{

public static void main(String a[])
{
System.out.prinltn("Hello");

}

}


I want o/p to be = "Hello" and not Hello

thanx in advance
[ June 05, 2006: Message edited by: Neha Mohit ]
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I don't understand your question.
Neha Mohit
Ranch Hand

Joined: Apr 25, 2006
Posts: 87
simple keith , i want o/p to be Hello in double quotes like this "Hello"

the above code when executes gives o/p as Hello , i want the Hello in quotes
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
how about this?

System.out.println((char)34+"Hello"+(char)34);

-W.O.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Sorry, I read your message before you added the code.

You can print a quote out by escaping it inside a String.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

To elaborate: to include a double quote in a String literal, use the two characters \" :

System.out.println("\"Hello\"");


[Jess in Action][AskingGoodQuestions]
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
For the complete list of charaters that require escaping see JLS


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
stephen shields
Greenhorn

Joined: Jun 05, 2006
Posts: 20
to be basic
to print " " i think you put

somestring = "\" Hello \"";
Neha Mohit
Ranch Hand

Joined: Apr 25, 2006
Posts: 87
Thanks to all of you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print in Double quotes ?
 
Similar Threads
output with single quotes
seek regular expression
what is the diff? (Strings again)
StringSplit regex question: missing part of my string?
String variable