-2

I need to make a string with the following content:

<head>    
<meta name="keywords" content="HTML, meta tags, metadata" />
</head>

Because of all of the quotation marks, not all of the words are included.

2 Answers2

3

I think you're looking for this

String str = "<head>\n<meta name=\"keywords\" "
    + "content=\"HTML, meta tags, metadata\" />\n</head>";
System.out.println(str);

Which outputs

<head>
<meta name="keywords" content="HTML, meta tags, metadata" />
</head>
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

you can escape the individual quotations:

<head>    
<meta name=\"keywords\" content=\"HTML, meta tags, metadata\" />
</head>
Aniket Inge
  • 25,375
  • 5
  • 50
  • 78