I have seen this cod, why it works please?
public void nеw() {
System.out.println("!?");
}
It is compile in java, I think new is a reserved word
I have seen this cod, why it works please?
public void nеw() {
System.out.println("!?");
}
It is compile in java, I think new is a reserved word
It is a cyrillic е, not a latin e. Therefore, it looks like new, but is actually a different method name.
Like NPE said, I would recommend reading is it a good idea to use unicode symbols as java identifiers?
Look at the hex dump:
$ xxd -g 1 code.java
0000000: 70 75 62 6c 69 63 20 76 6f 69 64 20 6e d0 b5 77 public void n..w
↑↑ ↑↑ ↑↑
0000010: 28 29 20 7b 0a 20 20 20 20 53 79 73 74 65 6d 2e () {. System.
0000020: 6f 75 74 2e 70 72 69 6e 74 6c 6e 28 22 21 3f 22 out.println("!?"
0000030: 29 3b 0a 7d 0a 0a );.}..
The "e" is not the Latin "e". It is a CYRILLIC SMALL LETTER IE (U+0435 encoded in UTF-8). Therefore the nеw
in the code is not the new
keyword, but is an identifier that happens to look like the new
keyword.
Take a look at Is it a good idea to use unicode symbols as Java identifiers?