我该如何打印“\t” (看起来像)在Java? [英] How can I print "\t" (as it looks) in Java?

查看:279
本文介绍了我该如何打印“\t” (看起来像)在Java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Java打印反斜杠。但每当我尝试时,它实际上将其作为\t运算符。
双反斜杠不起作用。我怎么能这样做。

I want to print backslash t in Java. But whenever I try, it actualy takes it as \t operator. Double backslash didn't work. How can I do that.

推荐答案

通过添加另一个来逃避反斜杠,例如

Escape the backslash by adding another, for example

System.out.println("This is a tab \t and this is not \\t");

如果这不起作用,您的代码可能还有其他问题 - 请将其发布这对你没有帮助。

If this doesn't work, there might be something else wrong in your code - please post it if this doesn't help you.

这篇关于我该如何打印“\t” (看起来像)在Java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆