I found this on the Internet:-
class M{public static void main(String[]a){System.out.print(new char[]
{'H','e','l','l','o',' ','W','o','r','l','d','!'});}}
This code prints Hello World! onto the screen. Clearly it can be seen public static void main is written backwards. How does this code work? How does this even compile?
Alex Flasch
Web Developer, Javascript Fanatic, Vue.js Enthusiast
After playing around with it, I noticed the (what appears to be) right parenthesis after the M. I found that curious, since that wouldn't work in a backwards program, so I deleted it, and everything happened to go back to normal!
After that, I figured that it must not actually be a right parenthesis, and in fact some sort of weird unicode character being displayed as a right parenthesis for whatever reason.
I proceeded to this unicode character lookup, copy + pasted the weird character and I was right! It turns out this character is actually a right-to-left override character, and effectively reverses all the characters on that line!
I'll note that this actually didn't compile for me. I used an online java compiler to try it out quick, but it didn't seem to like that RLO character. So this may or may not work depending on the exact compiler version or possibly other properties of your system.