Aan de slagGa gratis aan de slag

Email checking

You want to check email addresses. As email addresses always have to contain at least one @ character and a . afterwards, you can check this with a two-part logical expression.

Deze oefening maakt deel uit van de cursus

Intermediate Java

Cursus bekijken

Oefeninstructies

  • Choose the correct logical operator to put in the logical expression.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

class EMailChecker {
  public static void main(String[] args) {
    String address = "[email protected]";
    int addLen = address.length();

    // Write the correct logical operator to make sure the address is valid
    if (address.contains("@") ____ address.charAt(addLen - 4) == '.') {
      System.out.println("Send that email !");
    } else {
      System.out.println("That's not a valid email");
    }
  }
}
Code bewerken en uitvoeren