Update Main.java

added syntaxCheck and testing cases