Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Email Validation | String Advanced
Java Extended
course content

Course Content

Java Extended

Java Extended

1. Deep Java Structure
2. Methods
3. String Advanced
4. Classes
5. Classes Advanced

book
Challenge: Email Validation

Task

Swipe to start coding

Implement email validation by trimming any leading and trailing spaces from the string. Then, check the email's validity based on three conditions: there must be characters before the @ symbol, there must be characters after the @, and the domain after the @ must contain a dot. If the email is valid, extract and display the domain (the part after the @ symbol, excluding the symbol itself).

  1. In the validateEmail method, find the index of the @ symbol in the email.
  2. In the validateEmail method, find the index of the last dot (.) symbol in the email.
  3. Check that the @ index is greater than 0, and the dot index is greater than the @ index and less than the length of the email minus 1.
  4. In the extractDomainFromEmail method, find the index of the @ symbol in the email.
  5. Extract and return the substring starting from the character immediately after @ in the extractDomainFromEmail method.
  6. In the main method, trim any leading and trailing spaces from the email string.

Solution

java

solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 7
toggle bottom row

book
Challenge: Email Validation

Task

Swipe to start coding

Implement email validation by trimming any leading and trailing spaces from the string. Then, check the email's validity based on three conditions: there must be characters before the @ symbol, there must be characters after the @, and the domain after the @ must contain a dot. If the email is valid, extract and display the domain (the part after the @ symbol, excluding the symbol itself).

  1. In the validateEmail method, find the index of the @ symbol in the email.
  2. In the validateEmail method, find the index of the last dot (.) symbol in the email.
  3. Check that the @ index is greater than 0, and the dot index is greater than the @ index and less than the length of the email minus 1.
  4. In the extractDomainFromEmail method, find the index of the @ symbol in the email.
  5. Extract and return the substring starting from the character immediately after @ in the extractDomainFromEmail method.
  6. In the main method, trim any leading and trailing spaces from the email string.

Solution

java

solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 7
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt