Skip to content

Commit 96ca04f

Browse files
committed
feat: Add basic email parsing and Gmail domain detection in EmailValidate class
- Prompted user for an email address via Scanner. - Parsed the email string to: - Extract the username (substring before '@') - Extract the domain name (substring after '@') - Printed both username and domain. - Checked if domain starts with "Gmail" (case-sensitive). - Extracted the domain prefix (substring before first '.') and validated if it's "gmail" (case-insensitive). - Closed Scanner to prevent memory/resource leaks. Note: - This version assumes valid email format and does not perform safety checks for missing '@' or '.'. - Can be improved by adding validation before substring operations to prevent runtime exceptions. Signed-off-by: Somesh diwan <[email protected]>
1 parent 0e21c25 commit 96ca04f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Section6StringClassPrinting/src/EmailValidate.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import java.util.Scanner;
22

33
public class EmailValidate {
4-
public static void main(String[] args)
5-
{
4+
public static void main(String[] args) {
65
Scanner scanner = new Scanner(System.in);
76

87
System.out.print("Enter your email address: ");
@@ -24,4 +23,4 @@ public static void main(String[] args)
2423

2524
scanner.close();
2625
}
27-
}
26+
}

0 commit comments

Comments
 (0)