Java equivalent of Python repr()?

后端 未结 9 1897
醉酒成梦
醉酒成梦 2020-12-18 18:18

Is there a Java method that works like Python\'s repr? For example, assuming the function were named repr,

\"foo\\n\\tbar\".repr()

would re

9条回答
  •  庸人自扰
    2020-12-18 19:07

    If there were such a method, it would make writing quines in Java really easy, because it would solve the problem of escaping the quotes. Seeing as the simplest quines in Java all require manually inserting the quote character manually with its character code, it is unlikely that such a method exists.

提交回复
热议问题