I\'ve tried both the example in Oracle\'s Java Tutorials. They both compile fine, but at run-time, both come up with this error:
Exception in thread \"main\"
It happened to me in Android Studio.
The solution that worked for me: just restart the studio.