How is this valid Java code? (obfuscated Java)
One way to decipher what is going on is to look at the program character-by-character (demo).
There you may discover that characters in positions 7
and 42
are special UNICODE characters RLO
(right-to-left order) and LRO
(left-to-right order) characters.
Once you remove them, the program starts to look normal:
class M{public static void main(String[]a){System.out.print(new char[]{'H','e','l','l','o',' ','W','o','r','l','d','!'});}}
The trick to why the obfuscated program compiles is that Java compiler ignores these special characters as a format character.