Java Code Derived From Javascript Logic Is Not Working Properly Stack

Java Code Derived From Javascript Logic Is Not Working Properly Stack