Skip to content

Commit f46dce0

Browse files
committed
feat: Add Email class to validate and parse email address input
- Prompted user to input an email address using `Scanner`. - Performed basic email format validation by checking presence of '@' and '.'. - If valid, extracted: - Username (substring before '@') - Domain name (substring after '@') - Printed extracted username and domain name. - Added check to verify if domain starts with "Gmail" (case-sensitive). - Further extracted and checked if domain equals "gmail" (case-insensitive) before the '.' character. - Closed the Scanner object to release resources. This class offers a simple yet effective way to parse email addresses and identify Gmail domains, useful for input validation and domain-specific processing. Signed-off-by: Somesh diwan <[email protected]>
1 parent 796dd6c commit f46dce0

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

Section6StringClassPrinting/src/Email.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ public static void main(String[] args) {
2828
String name = domainname.substring(0, j);
2929
System.out.println("Is it a valid Gmail domain (case-insensitive)? " + name.equalsIgnoreCase("gmail"));
3030
}
31-
32-
// Close the scanner
3331
scanner.close();
3432
}
3533
}

0 commit comments

Comments
 (0)