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.
Bài tập này là một phần của khóa học
Intermediate Java
Hướng dẫn bài tập
- Choose the correct logical operator to put in the logical expression.
Bài tập tương tác thực hành trực tiếp
Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.
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");
}
}
}