Keey
Keey

Reputation: 23

Create a Java String variable with string formatting

I need to create a String variable . that should be like following variable.

String search = "xmlns="http://tempuri.org/" />";

but I cannot assign xmlns="http://tempuri.org/" /> directly into a String variable because tempuri.org/" />"; get commented automatically.

I need a format this string and finally variable should be like this

search = xmlns="http://tempuri.org/" /> ;

How can I achieve this ?

Upvotes: 0

Views: 82

Answers (2)

matthias
matthias

Reputation: 947

You need to use escape characters:

String search = "xmlns=\"http://tempuri.org/\" />";

Version from the comments:

String search = "xmlns=\"tempuri.org/\"; /></soap:Body>";

Upvotes: 2

You have to escape the special chars i.e replace the " for \"

String search = "xmlns=\"http://tempuri.org/\" />";

Upvotes: 1

Related Questions