繁体   English   中英

在 if 中使用 && 时出现此错误

[英]i am getting this error while using && in if

Solution.java:30: error: illegal character: '\u202c'
                if(x>=-2147483648‬ && x<=2147483647)
                                 ^
Solution.java:30: error: not a statement
                if(x>=-2147483648‬ && x<=2147483647)
                                   ^
Solution.java:30: error: ';' expected
                if(x>=-2147483648‬ && x<=2147483647)
                                                   ^
Solution.java:34: error: illegal character: '\u202c'
                if(x>=-(pow(2,61))‬ && x<=pow(2,61)-1)
                                  ^
Solution.java:34: error: not a statement
                if(x>=-(pow(2,61))‬ && x<=pow(2,61)-1)
                                    ^
Solution.java:34: error: ';' expected
                if(x>=-(pow(2,61))‬ && x<=pow(2,61)-1)
                                                     ^
6 errors

正如评论所指出的,在第一个与符号之前的第一个空格之前有一个额外的字符。 以下是您如何使用 java 来判断。

public static void printStringDetails(String s) {
for (int i = 0; i < s.length(); i++) {
    System.out.println(s.charAt(i) + " " + (int)(s.charAt(i)));
}
}

public static void main(String args[]) {
    String s = "if(x>=-2147483648‬ && x<=2147483647)";
    printStringDetails(s);
    s = "if(x>=-(pow(2,61))‬ && x<=pow(2,61)-1)";
    printStringDetails(s);
}

我粘贴你的字符串的地方。输出是:

i 105
f 102
( 40
x 120
> 62
= 61
- 45
2 50
1 49
4 52
7 55
4 52
8 56
3 51
6 54
4 52
8 56
‬ 8236
  32
& 38
& 38
  32
x 120
< 60
= 61
2 50
1 49
4 52
7 55
4 52
8 56
3 51
6 54
4 52
7 55
) 41
i 105
f 102
( 40
x 120
> 62
= 61
- 45
( 40
p 112
o 111
w 119
( 40
2 50
, 44
6 54
1 49
) 41
) 41
‬ 8236
  32
& 38
& 38
  32
x 120
< 60
= 61
p 112
o 111
w 119
( 40
2 50
, 44
6 54
1 49
) 41
- 45
1 49
) 41

请注意每行中第一个与号之前的空格 (ASCII 32) 之前出现的两次 8236。 然后您可以返回并进行编辑,以便输出符合您的预期。 因此:

if(x>=-2147483648 && x<=2147483647)

(将其粘贴在引号之间,您将看到我删除了不需要的字符)和

if(x>=-(pow(2,61)) && x<=pow(2,61)-1)

应该修复它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM