Does Java have the '@' character to escape string quotes?

后端 未结 2 1819
情深已故
情深已故 2020-12-10 14:37

My string has double quotes in it, in C# I would do:

string blah = @\"this is my \"\"text\";

how would I do that in Java?

2条回答
  •  悲哀的现实
    2020-12-10 14:52

    There is nothing like it currently, but it is a "Fix understood" request for enhancement.

    • Bug ID 4472509: Add support for vertabim(sic) string literals

    If added, this feature would allow such string literals:

    String qry = @"
       SELECT
         a.name, b.number
       FROM
         User a, Data b
       WHERE
         a.name = "James"
          AND
         a.id = b.id
    ";
    

    Some of the comments reject this principally on the fact that it's a syntactic sugar, but obviously there's high demand for it, so it's possible that we'll see this someday.

提交回复
热议问题