Skip to content

Commit 8d8e1a9

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 f46dce0 commit 8d8e1a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Section6StringClassPrinting/src/Email.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class Email {
44
public static void main(String[] args) {
55
Scanner scanner = new Scanner(System.in);
66

7-
// Prompt user to enter an email address
7+
// Prompt the user to enter an email address
88
System.out.print("Enter your email address: ");
99
String str = scanner.nextLine();
1010

0 commit comments

Comments
 (0)