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

Kurssisisältö

Java Extended

Java Extended

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

book
Challenge: Email Validation

Tehtävä

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.

Ratkaisu

java

solution

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 7
toggle bottom row

book
Challenge: Email Validation

Tehtävä

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.

Ratkaisu

java

solution

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 7
Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt