Language: Java

class ViewController: UIViewController {

  var loginButton: UIButton!
  var nameTextField: UITextField!
  var passwordTextField: UITextField!

  override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = .white

    loginButton = UIButton(type: .system)
    loginButton.setTitle("Login", for: .normal)
    loginButton.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(loginButton)
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)

    nameTextField = UITextField(frame: .zero)
    nameTextField.placeholder = "Login Name"
    nameTextField.borderStyle = .roundedRect
    nameTextField.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(nameTextField)

    passwordTextField = UITextField(frame: .zero)
    passwordTextField.placeholder = "Password"
    passwordTextField.isSecureTextEntry = true
    passwordTextField.borderStyle = .roundedRect
    passwordTextField.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(passwordTextField)

    constraintsInit()
  }

  func constraintsInit() {
    NSLayoutConstraint.activate([
      loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
      loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),

      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
      passwordTextField.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -20),

      nameTextField.bottomAnchor.constraint(equalTo: passwordTextField.topAnchor, constant: -20),
      nameTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
      nameTextField.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -20)
    ])
  }

  @objc func handleLoginTouchUpInside() {
    print("Login has been tapped")
    if nameTextField.isFirstResponder {
      nameTextField.resignFirstResponder()
    }
    if passwordTextField.isFirstResponder {
      passwordTextField.resignFirstResponder()
    }
  }
}

Compiler output:
Main.java:1: error: '{' expected
class ViewController: UIViewController {
                    ^
Main.java:3: error: 'var' is not allowed here
  var loginButton: UIButton!
  ^
Main.java:3: error: ';' expected
  var loginButton: UIButton!
                 ^
Main.java:3: error: <identifier> expected
  var loginButton: UIButton!
                           ^
Main.java:4: error: 'var' is not allowed here
  var nameTextField: UITextField!
  ^
Main.java:4: error: ';' expected
  var nameTextField: UITextField!
                   ^
Main.java:4: error: <identifier> expected
  var nameTextField: UITextField!
                                ^
Main.java:5: error: 'var' is not allowed here
  var passwordTextField: UITextField!
  ^
Main.java:5: error: ';' expected
  var passwordTextField: UITextField!
                       ^
Main.java:5: error: <identifier> expected
  var passwordTextField: UITextField!
                                    ^
Main.java:7: error: ';' expected
  override func viewDidLoad() {
               ^
Main.java:7: error: invalid method declaration; return type required
  override func viewDidLoad() {
                ^
Main.java:8: error: ';' expected
    super.viewDidLoad()
                       ^
Main.java:9: error: illegal start of expression
    view.backgroundColor = .white
                           ^
Main.java:11: error: ')' or ',' expected
    loginButton = UIButton(type: .system)
                               ^
Main.java:11: error: not a statement
    loginButton = UIButton(type: .system)
                                  ^
Main.java:11: error: ';' expected
    loginButton = UIButton(type: .system)
                                        ^
Main.java:12: error: illegal start of expression
    loginButton.setTitle("Login", for: .normal)
                                  ^
Main.java:12: error: '(' expected
    loginButton.setTitle("Login", for: .normal)
                                     ^
Main.java:12: error: illegal start of expression
    loginButton.setTitle("Login", for: .normal)
                                       ^
Main.java:12: error: not a statement
    loginButton.setTitle("Login", for: .normal)
                                        ^
Main.java:12: error: ';' expected
    loginButton.setTitle("Login", for: .normal)
                                              ^
Main.java:13: error: ';' expected
    loginButton.translatesAutoresizingMaskIntoConstraints = false
                                                                 ^
Main.java:14: error: ';' expected
    view.addSubview(loginButton)
                                ^
Main.java:15: error: ')' or ',' expected
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                      ^
Main.java:15: error: illegal character: '#'
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                        ^
Main.java:15: error: ';' expected
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                                                           ^
Main.java:15: error: '(' expected
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                                                                ^
Main.java:15: error: illegal start of expression
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                                                                  ^
Main.java:15: error: not a statement
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                                                                   ^
Main.java:15: error: ';' expected
    loginButton.addTarget(self, action: #selector(handleLoginTouchUpInside), for: .touchUpInside)
                                                                                                ^
Main.java:17: error: ')' or ',' expected
    nameTextField = UITextField(frame: .zero)
                                     ^
Main.java:17: error: not a statement
    nameTextField = UITextField(frame: .zero)
                                        ^
Main.java:17: error: ';' expected
    nameTextField = UITextField(frame: .zero)
                                            ^
Main.java:18: error: ';' expected
    nameTextField.placeholder = "Login Name"
                                            ^
Main.java:19: error: illegal start of expression
    nameTextField.borderStyle = .roundedRect
                                ^
Main.java:20: error: ';' expected
    nameTextField.translatesAutoresizingMaskIntoConstraints = false
                 ^
Main.java:20: error: ';' expected
    nameTextField.translatesAutoresizingMaskIntoConstraints = false
                                                                   ^
Main.java:21: error: ';' expected
    view.addSubview(nameTextField)
                                  ^
Main.java:23: error: ')' or ',' expected
    passwordTextField = UITextField(frame: .zero)
                                         ^
Main.java:23: error: not a statement
    passwordTextField = UITextField(frame: .zero)
                                            ^
Main.java:23: error: ';' expected
    passwordTextField = UITextField(frame: .zero)
                                                ^
Main.java:24: error: ';' expected
    passwordTextField.placeholder = "Password"
                                              ^
Main.java:25: error: ';' expected
    passwordTextField.isSecureTextEntry = true
                                              ^
Main.java:26: error: illegal start of expression
    passwordTextField.borderStyle = .roundedRect
                                    ^
Main.java:27: error: ';' expected
    passwordTextField.translatesAutoresizingMaskIntoConstraints = false
                     ^
Main.java:27: error: ';' expected
    passwordTextField.translatesAutoresizingMaskIntoConstraints = false
                                                                       ^
Main.java:28: error: ';' expected
    view.addSubview(passwordTextField)
                                      ^
Main.java:30: error: ';' expected
    constraintsInit()
                     ^
Main.java:34: error: illegal start of expression
    NSLayoutConstraint.activate([
                                ^
Main.java:35: error: ')' or ',' expected
      loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
                                                  ^
Main.java:35: error: not a statement
      loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
                                                        ^
Main.java:35: error: ';' expected
      loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor),
                                                                      ^
Main.java:36: error: ')' or ',' expected
      loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
                                                  ^
Main.java:36: error: not a statement
      loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
                                                        ^
Main.java:36: error: ';' expected
      loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor),
                                                                      ^
Main.java:38: error: ')' or ',' expected
      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
                                                       ^
Main.java:38: error: not a statement
      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
                                                                    ^
Main.java:38: error: ';' expected
      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
                                                                              ^
Main.java:38: error: not a statement
      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
                                                                                          ^
Main.java:38: error: ';' expected
      passwordTextField.bottomAnchor.constraint(equalTo: loginButton.topAnchor, constant: -20),
                                                                                             ^
Main.java:39: error: ')' or ',' expected
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
                                                        ^
Main.java:39: error: not a statement
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
                                                                                   ^
Main.java:39: error: ';' expected
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
                                                                                                 ^
Main.java:39: error: not a statement
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
                                                                                                             ^
Main.java:39: error: ';' expected
      passwordTextField.leadingAnchor.constraint(equalTo: view.readableContentGuide.leadingAnchor, constant: 20),
                                                                                                               ^
Main.java:40: error: ')' or ',' expected
      passwordTextField.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -20),
                                                         ^
Main.java:40: error: not a statement
      passwordTextField.trailingAnchor.constraint(equalTo: view.readableContentGuide.trailingAnchor, constant: -20),