简体   繁体   中英

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

As the comments have pointed out, there is an extra character in there before the first space before the first ampersand. Here is how you could use java to tell.

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);
}

where I pasted your strings in. Output is:

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

Notice the two occurrences of 8236 before the space (ASCII 32) before the first ampersand in each line. Then you can go back in and edit so that the output is what you expect. Thus:

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

(paste that between the quotes and you will see I deleted the unwanted character) and

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

should fix it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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