Skip to content

Commit 0e21c25

Browse files
committed
feat: Enhance email validation and Gmail domain detection in Email2 class
- Prompted user to enter an email address via Scanner. - Improved email validation by checking both presence of '@' and that '.' appears after '@'. - Extracted: - Username (substring before '@') - Domain name (substring after '@') - Displayed extracted username and domain. - Checked whether the domain: - Starts with "gmail" (case-insensitive) - Is exactly "gmail.com" (case-insensitive), by parsing substring before first '.' - Handled cases where domain is malformed (i.e., no '.' after '@'). - Closed Scanner to prevent resource leak. This update improves robustness in email parsing and provides accurate checks for Gmail domains. Signed-off-by: Somesh diwan <[email protected]>
1 parent 8d8e1a9 commit 0e21c25

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Section6StringClassPrinting/src/Email2.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public static void main(String[] args) {
3434
} else {
3535
System.out.println("Invalid email format. Please enter a valid email address.");
3636
}
37-
3837
scanner.close();
3938
}
40-
}
39+
}

0 commit comments

Comments
 (0)