How to print value with ""

Hi All,

I am trying to print a String with "Value" can anyone please provide me a code sample for that.

What I am trying to print is -

String Result = "a" + "b";

System.out.println("Result = " + Result );

This is giving me Result = ab

Where as I want Result = "ab"

Thanks in Advance

Sameer

[349 byte] By [santosh_13va] at [2007-10-3 5:26:26]
# 1

public static void main(String[] args)

{

String result = "\"ab\"";

System.out.println( result );

}

The " is a special character in java. If you want to add a " to a string you must first escape it with a slash like so \"

Norweeda at 2007-7-14 23:33:41 > top of Java-index,Java Essentials,Java Programming...
# 2
You have to use the escape character.System.out.println("Result = \"" + Result + "\"");So to print a double quote you have to append a \ character in front of it[ edit ] dang, too late[ /edit ]
gimbal2a at 2007-7-14 23:33:41 > top of Java-index,Java Essentials,Java Programming...
# 3
Thanks it worked :)
santosh_13va at 2007-7-14 23:33:41 > top of Java-index,Java Essentials,Java Programming...