非法逃脱字符“\” [英] Illegal Escape Character "\"

查看:258
本文介绍了非法逃脱字符“\”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想得到一个链接的最后的名称,所以我做了

i want to get the name at the final of a link so i did that

if( invName.substring(j,k).equals("\")){
                                 copyf=invName.substring(0,j);}

$ b b

所以eclipse说的字符串文字没有被一个双引号正确关闭

so eclipse said String literal is not properly closed by a double-quote

我如何使用这个char \

how can i compaire String with this char \

推荐答案

字符'\'是一个特殊字符,需要在用作字符串的一部分时进行转义,例如\ 。下面是使用'\'字符的字符串比较示例:

The character '\' is a special character and needs to be escaped when used as part of a String, e.g., "\". Here is an example of a string comparison using the '\' character:

if (invName.substring(j,k).equals("\\")) {...}

字符比较使用类似于以下逻辑:

You can also perform direct character comparisons using logic similar to the following:

if (invName.charAt(j) == '\\') {...}

这篇关于非法逃脱字符“\”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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