[如果在使用&&时出现此错误

问题描述 投票:-1回答:1
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
1个回答
0
投票

正如评论所指出的那样,在第一个&符之前的第一个空格之前,还有一个额外的汉字。这是您可以使用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)

应该修复它。

© www.soinside.com 2019 - 2024. All rights reserved.