打印“\”使用System.out.println在Java中键入 [英] Printing the "\" key in Java using System.out.println

查看:91
本文介绍了打印“\”使用System.out.println在Java中键入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在输出的一部分中使用 \ 键。

I am trying to use the \ key in part of my output.

当前通过谷歌搜索不是证明是成功的,也许我称之为错误的东西(反斜杠,逃避角色等)我无法找到任何代码或如何使eclipse明白我想要真正打印那个角色,而且我'我没有尝试某种转义码。

Current searches via google are not proving to be successful, perhaps I'm calling it the wrong thing (back slash, escape character, etc.) I cannot find anywhere the code or how to make eclipse understand I want to actually print that character, and that I'm not attempting some sort of escape code.

有没有办法做到这一点?

Is there a way to do this?

推荐答案

你必须双重转义它,因为它是转义字符:

You have to double-escape it, since it is the escape character:

System.out.println( \\);

这篇关于打印“\”使用System.out.println在Java中键入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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