Quick Java programming question involving quotation marks.

BHeemsoth

Platinum Member
Jul 30, 2002
2,738
0
76
Please don't flame me; I am new to Java.

I am trying to make a program that displays a variable as part of a string.

For example.

System.out.println("Book: " + title);

I need to surround the variable title with double quotation marks. When I try to do as my book says (/") I get Syntax errors.

Any ideas?

As always, thank you in advance.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
what you want is \", not /" :)

eg
System.out.println("Book\"" + title + "\"");
 

ArmchairAthlete

Diamond Member
Dec 3, 2002
3,763
0
0
dighn's code should work fine, what these are called are escape sequences btw. Google "java escape sequences" to see more.
 

BHeemsoth

Platinum Member
Jul 30, 2002
2,738
0
76
Originally posted by: ArmchairAthlete
dighn's code should work fine, what these are called are escape sequences btw. Google "java escape sequences" to see more.

Yeah, I learned about those. However, I was putting them in the wrong places in the skin.